gridview的可空参考 [英] nullable reference of gridview

查看:80
本文介绍了gridview的可空参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误是:对象引用未设置为对象的实例。



描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.NullReferenceException:对象引用未设置为实例一个对象。



来源错误:





第21行:

第22行:}

第23行:GridView1.Visible = false; //在这条线上错误显示无效参考

第24行:

第25行:}





提前感谢

ERROR is : Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 21:
Line 22: }
Line 23: GridView1.Visible = false; //ON THIS LINE ERROR IS SHOWN OF NULLABLE REFERENCE
Line 24:
Line 25: }


thanks in advance

推荐答案

我们无法为你解决这个问题:由你决定。



首先查看代码,找到对GridView1的每个引用。

查看是否有任何值赋予该值。

如果有,请查看确切分配的内容 - 检查是否有效且不为空。在某些时候,需要为它分配一个新的Gridview(... 值。

如果没有,那么你需要知道为什么不呢。这意味着要查看你的其余代码并试图找出你的意图,以及你做了什么!



但是我们不能为你做到 - 我们无法访问你的代码!
We can't solve this for you: it's up to you.

Start by looking in your code, and find every reference to "GridView1".
Look to see if there is anywhere which assigns a value to that.
If there is, look at exactly what is being assigned - check that that is valid and not null. At some point, it needs to be assigned a new Gridview(... value.
If there isn't, then you need to know why not. And that means looking at the rest of your code and trying to find out what you meant to do, and what it was you did instead!

But we can't do that for you - we don't have access to your code!


这篇关于gridview的可空参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆