I'm using the following code in attempt to allow the user to select a gridview row by clicking anywhere on the row (plus mouse over and out) effects. The code doesn't seem to be applied on rowdatabound and I can't break into the event. (It is wired).
The control is in a usercontrol, that lives in a content page, which has a masterpage.
protected void gvOrderTypes_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView gvOrdTypes = (GridView)sender;
//check the item being bound is actually a DataRow, if it is,
//wire up the required html events and attach the relevant JavaScripts
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
e.Row.Attributes["onclick"] = Page开发者_如何学编程.ClientScript.GetPostBackClientHyperlink(gvOrdTypes, "Select$" + e.Row.RowIndex);
}
}
Scratch that. The handler was wired to the databound event instead of rowdatabound. Sorry everyone. As a side note, the code works
精彩评论