焚寂六月 2017-05-02 11:54 采纳率: 0%
浏览 935
已采纳

未将对象引用设置到对象的实例

写了个Button的Click事件处理程序
```protected void bntLook_Click(object sender, EventArgs e)
{
Button btnLook = sender as Button;
GridViewRow gr = btnLook.Parent.Parent as GridViewRow;//这里报错
Response.Redirect("Information.aspx?labID = " + gr.Cells[1].ToString());
return;
}
这是怎么回事
bntLook和gr是null
我按照这上面写的http://www.cnblogs.com/jy02414216/archive/2012/08/10/2633086.html

  • 写回答

1条回答 默认 最新

  • 普通网友 2017-05-02 11:58
    关注

    看看是不是这个对象有问题,加断点调试看看吧

     btnLook.Parent.Parent
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?