I want to select a row without using a button column, but instead just click
anywhere on the row. I also don't want to write a new control.
I am using the following code to create an onclick attribute to each cell
and I want to call my function onClickTableCell(), but when I click the
DataGrid, it does a postback, but doesn't call my function.
public void itemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
foreach( DataGridItem dgi in dgList.Items )
{
if ( dgi.ItemType != ListItemType.Header &&
dgi.ItemType != ListItemType.Footer &&
dgi.ItemType != ListItemType.Pager )
{
dgi.Attributes["onclick"] =
Page.GetPostBackClientHyperlink(dgi, "onClickTableCell");
}
}
}
public void onClickTableCell(object sender, EventArgs e)
{
// do the selection here.
string szClientId = dgList.ID;
}
Each row of my datagrid looks like the following:
<tr onclick="javascript:__doPostBack('dgList:_ctl2','o nClickTableCell')"
style="background-color:#DEE1F5;">
what do I need to do to get my onClickTableCell method called?
Thanks,
Tim