protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string s = "window.opener.document.getElementById('ctl00_MainContent_TextBox1').value='" + e.Row.Cells[0].Text + "';";
string s1 = "window.opener.document.getElementById('ctl00_MainContent_TextBox2').value='" + e.Row.Cells[1].Text + "'; window.close();";
e.Row.Attributes.Add("ondblclick", s+s1);//双击选择
//当鼠标移到的时候设置该行颜色为"", 并保存原来的背景颜色
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C0C0FF';this.style.cursor='hand';");
//当鼠标移走时还原该行的背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
注意,先要判断是否数据行,再进行string的赋值,否则会出现 指定的参数已超出有效值的范围 的错误提示。
转载于:https://www.cnblogs.com/zhenshiruwo/archive/2008/01/31/1060331.html