日期:2014-05-17  浏览次数:20444 次

gridview行点击事件提示缺少对象
现在的想法是当在某页点击按钮时,弹出新页面,在新页面中点击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();
        }