【发布时间】:2010-06-15 17:56:33
【问题描述】:
我正在使用以下代码来尝试允许用户通过单击行上的任意位置(加上鼠标悬停和移出)效果来选择 gridview 行。该代码似乎没有应用于 rowdatabound,我无法闯入事件。 (是有线的)。
该控件位于用户控件中,该控件位于具有母版页的内容页面中。
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);
}
}
【问题讨论】: