与Dataset和datareader一起举行 [英] Held with Dataset and datareader

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

问题描述

大家好,我有2个问题



问题一:

我正在尝试在ASP中为gridview分配一个datareader .NET,一切都很成功,除了我无法选择,排序和分页我的gridview。我在网上找到了一些例子,但都没有明确解释。我很感激,如果有人可以帮我解决这个问题并给出清楚的解释。



问题二:

我想要通过数据集将行缓存分配给TextBox

Hi guys, I have 2 Questions

QUESTION ONE:
I''m trying to assign a datareader to gridview in ASP.NET, everything was successful except that i can not select, sort and page my gridview. I''ve found bunches of examples online but all are not clearly explain. I''ll appreciate if any one can help me out with this and a clear explanation of it.

QUESTION TWO:
I wan to assign the rows cache by a dataset to TextBox

推荐答案

通常,我命令对gridview记录集进行排序,我们将从数据源表中形成数据视图。由于dataview对象直接支持Datatable的重载,因此我们将数据集或数据表作为gridviews的绑定源。然后我们将基于排序表达式对数据视图进行排序,并再次将该视图与网格绑定。因此,网格看起来就像它自己排序一样。



现在,如果您使用Datareader作为网格源,那么您无法直接对行进行排序。你必须使用DataReader激活的列和行创建新的DataTable,然后使用此DataTable创建Dataview,设置排序表达式并对视图进行排序并绑定网格。



类似于分页的情况。
Normally, I order to sort a gridview record set, we will form a dataview from the datasource table. since dataview object directly supports the overload for Datatable, we go for dataset or datatable as binding source for gridviews. Then we will sort inside the dataview based on the sort expression and bind that view with grid again. So, grid will look as it has sorted by itself.

Now, If you are using Datareader as your Grid Source, then you cannot directly sort the rows. you have to create new DataTable with the columns and rows spicified by DataReader, then use this DataTable for creating Dataview, set the sort expression and sort the view and bind the grid.

Similar case with paging also.


这篇关于与Dataset和datareader一起举行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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