Home All Groups Group Topic Archive Search About

link on an entire row in a datagrid

Author
3 Jan 2006 2:37 PM
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

Author
3 Jan 2006 2:44 PM
ThunderMusic
ok, never mind, I just found someone already did it.

sorry

Show quoteHide quote
"ThunderMusic" <NOSPAM@NoSPAM.Info> wrote in message
news:uXM%23HNHEGHA.140@TK2MSFTNGP12.phx.gbl...
> 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
>
Author
3 Jan 2006 9:47 PM
Keith Patrick
Got a link?
Author
3 Jan 2006 9:58 PM
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

Show quoteHide quote
"Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in message
news:ugq4K9KEGHA.336@TK2MSFTNGP14.phx.gbl...
> Got a link?
>
Author
4 Jan 2006 2:22 AM
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!
Author
9 Jan 2006 8:16 PM
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."