|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
link on an entire row in a datagridHi,
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 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 > 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? > 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! 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."
Any hints on how to do frames in ASP.Net 2.0?
Code to select item in dropdown populated using TableAdapter Custom Treenodes in Treeview Remove Dynamic User Controls from a collection Would like to get two items from a dropdownlist DropDownList VS TextBox Gridview - Accessing a field value in current row controlToValidate property of compareValidator combo box customs TreeView |
|||||||||||||||||||||||