gridview行点击事件提示缺少对象

7年 7年 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
现在的想法是当在某页点击按钮时,弹出新页面,在新页面中点击gridview中的一行。将这一行数据返回到父页面中。我在gridview加了一个checkbox的列。现在点击checkbox已经可以实现了,但是当点击gridview的行时,提示缺少对象。代码:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string username = ((System.Data.DataRowView)(e.Row.DataItem)).Row["Fusername"] as string;

string userpassword = ((System.Data.DataRowView)(e.Row.DataItem)).Row["Fuserpassword"] as string;

string userflag = ((System.Data.DataRowView)(e.Row.DataItem)).Row["fuserflag"] as string;

e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#8EC26F'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";

e.Row.Attributes.Add("onClick", "getuserInfo('" + username + "','" + userpassword + "','" + userflag + "')");
//e.Row.Attributes.Add("onClick", "test()");
}
}



function getInfo(Fusername, Fuserpassword, Fuserflag) {
alert(Fusername);
window.opener.getuserInfo(Fusername, Fuserpassword, Fuserflag);
window.close();
}

...全文
评论 22
收藏 已收藏
分享
返回顶部
7年
.NET社区 62,273 成员 668,968 内容