SQLDatasource参数问题

发布于 2024-10-16 16:19:32 字数 184 浏览 8 评论 0原文

为什么如果我在后面的代码中使用以下指令:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

饮湿 2024-10-23 16:19:32

该单个语句中涉及的唯一两个对象是(粗体)

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.

半葬歌 2024-10-23 16:19:32

您的 SqlDataSource 对象为 null 或者其 SelectParameters 集合没有“page”条目。检查您是否已正确定义该选择参数。

Either your SqlDataSource object is null or its SelectParameters collection doesn't have an entry for "page". Check that you have defined that select parameter appropriately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文