asp:SqlDataSource 到数据集项
我的aspx页面上有一个asp:SqlDataSource ID="SqlDataSource1"工具,我想要在后面的c# Sharp代码中做的就是传输数据源返回的记录并将它们放入DataSet中,以便我可以添加分页到我的页面,我该怎么做,到目前为止我的尝试都失败了?!
到目前为止,我的尝试是这样的:
DataSet Items = new DataSet(); 项目 = SqlDataSource1.Data();
但我得到的错误是 SqlDataSource1 控件在这种情况下无法访问,因此显然智能感知没有拾取它,因此“Data()”位对我来说完全是虚构的...
谢谢,R
I have an asp:SqlDataSource ID="SqlDataSource1" tool on my aspx page, what I want to do in the c# sharp code behind is transfer the records returned by the datasource and put them into a DataSet, so that I can add paging to my page, how do I do that, my attempts so far have failed?!
My attempts so far have been along the lines of:
DataSet Items = new DataSet();
Items = SqlDataSource1.Data();
But the error I am getting is that the SqlDataSource1 control is not accessible in this context and so obviously the intellisense is not picking it up, so the 'Data()' bit is complete fiction on my part...
Thanks, R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
flavor404,如果您正确设置了控件,则不应出现该错误。 我刚刚测试了您的场景,它可以正常工作,不会出现您提到的错误。
SqlDataSource1 没有任何 Data 方法,您可能正在寻找 Select() 方法,但它不返回 DataSet。 如果将 SqlDataSource.DataSourceMode 属性设置为“DataSet”,您将获得 DataView 对象。 请参阅下面的示例,
阅读 MSDN 了解详细信息:
http://msdn.microsoft.com /en-us/library/dz12d98w.aspx
http://msdn.microsoft.com/en-us/ Library/system.data.dataview.aspx
希望这有帮助!
flavour404, You should not get that error if you have set up the control properly. I just tested your scenario and it works with out the error you have mentioned.
SqlDataSource1 does not have any Data method, you might be looking for Select() method and it does not return DataSet. If you set SqlDataSource.DataSourceMode property to 'DataSet' you would get DataView object. See the sample below
Read MSDN for details:
http://msdn.microsoft.com/en-us/library/dz12d98w.aspx
http://msdn.microsoft.com/en-us/library/system.data.dataview.aspx
Hope this helps!
这应该有效! :)
This Should work! :)