绑定gridview1的RowDataBound事件
下面这个写法已经很全面了,包括将ID这个变量进行传参。请大家借鉴。
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#95B8FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
e.Row.Attributes["style"] = "Cursor:hand";
}
int count = GridView1.Rows.Count;
string ID = "";
for (int i = 0; i < count; i++)
{
ID =GridView1.DataKeys[i].Value.ToString();
GridView1.Rows[i].Attributes.Add("onclick", "newwin=window.open('要打开的文件?ID=" + ID + "','newwin','width=500,height=550')");
}
}
本文作者:佚名 来源:本站原创
CIO之家 www.ciozj.com 微信公众号:imciow