Clicking Gridview cell

  • Thread starter Thread starter Durango2008
  • Start date Start date
D

Durango2008

Hi, I have a Gridview which contains data derived from DB table within each
cell.
The cells are created using ItemTemplate containing Labels used for
displaying the data. What I would like to know is if there is a way to be
able to click on the cell to have the data display in another location on
the page?
I could not figure out how to do this so I instead made the labels into
buttons and used the onClick event, which worked fine.
The problem with buttons is, it does not look good within the Gridview
cells, I would rather somehow use Labels to achieve this.
If anyone can help me out I would appreciate it :)
Thank you very much.
 
Hi, I have a Gridview which contains data derived from DB table within each
cell.
The cells are created using ItemTemplate containing Labels used for
displaying the data.  What I would like to know is if there is a way to be
able to click on the cell to have the data display in another location on
the page?
I could not figure out how to do this so I instead made the labels into
buttons and used the onClick event, which worked fine.
The problem with buttons is, it does not look good within the Gridview
cells, I would rather somehow use Labels to achieve this.
If anyone can help me out I would appreciate it :)
Thank you very much.

Hi

If you use link buttons you can format them so they look like ordinary
text - just set the font-underline property to false and whatever
color etc you like. In a way you can think of link buttons as labels
that do postbacks.

HTH
 
Hi,

you can add javascript to labels by having code like:

Label1.Attributes.Add("onclick","alert('Label was clicked')")

e.g you could wire client-side script to do the stuff, in case that works
well enough. For server-side clicks to be raised you indeed need a Button or
a custom control (can implement IButtonControl interface or do it just by
causing postback from the click)

Developing a row-clickable GridView gives starters (it' s easy to adapt to
getting clicks from cells) if you'd want to do it that way
http://aspadvice.com/blogs/joteke/archive/2006/01/07/14576.aspx
 
Back
Top