
如何使用GridView数据行单击,双击事件
推荐于2017-12-15 · 知道合伙人数码行家

知道合伙人数码行家
采纳数:117525
获赞数:517238
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注

展开全部
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";
}
{
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";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询