ASP.Net Datagrid get Cell Contents on mouse click or mouse down

D

Davisro

I would like to get the cell contents of an asp.net datagrid when the mouse
is down? Mouse Click, cell click etc...


Is there a way to get this?



Thanks,

Rog
 
A

Alvin Bruney [MVP]

about the easiest way to do this is to place the items ahead of time, tied
to the mousedown event handler from the itemdatabound using the attributes
of the cell object. Once the data is streamed to the page, you can access
the data because it is inside the page itself
 
J

Jim Corey

Rog,

In the ItemDataBound event of the datagrid you can do something like
this:

If e.Item.ItemType = ListItemType.Item Then
e.Item.Cells(1).Attributes.Add("onclick", "alert('hi')")
End If

You might also add ListItemType.AlternatingItem (this event also fires
for the header, and you don't want it there).

You could add in variables as needed.

HTH,
Jim
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top