SQLDatasource参数问题
为什么如果我在后面的代码中使用以下指令:
SqlDataSource1.SelectParameters["page"].DefaultValue = "0";
我得到“System.NullReferenceException:未将对象引用设置为对象的实例”。
'?
Why if i use the following instruction in the code behind:
SqlDataSource1.SelectParameters["page"].DefaultValue = "0";
I get 'System.NullReferenceException: Object reference not set to an instance of an object.
'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该单个语句中涉及的唯一两个对象是(粗体)
SqlDataSource1.SelectParameters["page"].DefaultValue
SqlDataSource1.SelectParameters["page"].DefaultValue
因此其中之一它们必须为空。当将此问题与您之前的问题一起查看时,这是因为您尚未将“page”参数添加到
SqlDataSource1
中。The only two objects involves in that single statement are (bold)
SqlDataSource1.SelectParameters["page"].DefaultValue
SqlDataSource1.SelectParameters["page"].DefaultValue
So one of them must be null. When looking at this together with your previous question, it is because you have not yet added the "page" parameter to
SqlDataSource1
.您的
SqlDataSource
对象为 null 或者其SelectParameters
集合没有“page”条目。检查您是否已正确定义该选择参数。Either your
SqlDataSource
object is null or itsSelectParameters
collection doesn't have an entry for "page". Check that you have defined that select parameter appropriately.