link on an entire row in a datagrid

T

ThunderMusic

Hi,
In my page, I have a datagrid. I want a link to be "bound" to the entire
row. How can I do that? I have my datagrid, my colums and all, but how do I
add the link so when I click on anything in the row, it does something
(OnClick="MySomething")? Will I have to add the "OnClick" event to all my
rows?

Thanks

ThunderMusic
 
T

ThunderMusic

no, because it was in our code... Someone did it within our team...

we add a OnClick event on the created Item within the ItemCreated event of
the DataGrid like this:

e.Item.Attributes.Add("OnClick", "javascript:poP(" + e.Item.Cells[0].Text +
");");

I hope it helps

ThunderMusic
 
K

Keith Patrick

Cool, yeah, it's been something I've been wanting to put on a user screen
for over a year now but never sat down to try out any way to get it working,
but I'm at a point where I can redo the screen, so it's back on my tasklist.
Thanks!
 
K

Keith Patrick

BTW: I've found it's better to do this OnItemDataBound, as any templated
controls in there don't get a NamingContainer-qualified ClientID until the
binding has occured. This example has a radio button called "Selected" in
the first column:
if ( e.Item.ItemType != ListItemType.Item
&& e.Item.ItemType != ListItemType.AlternatingItem)
{
return;
}

e.Item.Attributes["onClick"] =
"javascript:document.getElementById('" +
e.Item.Cells[0].FindControl("Selected").ClientID + "').Selected = true;";



At ItemCreated, the ClientID is "Selected", wherease on DataBound, it's
"ctrl00_OwningDataGrid_Selected."
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top