如何使用GridView数据行单击,双击事件
发布网友
发布时间:2022-04-27 12:50
我来回答
共2个回答
热心网友
时间:2022-04-27 14:19
if (e.Row.RowType == DataControlRowType.DataRow)
{
string url = "Page.aspx?ID=" + e.Row.Cells[1].Text;
//鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
//单击/双击 事件
e.Row.Attributes.Add("OnDblClick", "window.open('" + url + "','', 'alwaysRaised=1,dependent=1,resizable=0,scrollbars,width=500,height=300')");
//e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[1].Text + "')");
//e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.Cells[1].Text + "')");
e.Row.Attributes.Add("OnClick", "javascirpt:__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
e.Row.Attributes.Add("OnKeyDown", "GridViewItemKeyDownEvent('" + e.Row.Cells[1].Text + "')");
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";
}