Clicking Gridview cell

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.
 
S

Stan

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
 
T

Teemu Keiski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top