开发者

How Can we use BindingSource.Filter Property to get rows form row count 30 to 50

I am using c#, datatable and bindingsource control. If we have a column name called as Recordsn in the dataset then We can filter as shown below.

bindingSource1.Filter = "Recordsn >= 30 and Recordsn <= 50" ;

However,In some cases I donot have the Recordsn column .Since Recordsn is just the row count , I believe that we can do the filter without having to inse开发者_开发技巧rt the Recordsn column in the dataset and still be able to filter the rows to get rows from certain starting row to ending row. Is there a way ? Thanks. Is there a way to do this on datatable if not possible on bindingsource Note : I have used 30 and 50 to just make the question simpler , it could be any range.


Setting the BindingSource.Filter property simply has that filter string value passed onto the IBindingListView that is the source attached to the BindingSource. The format of the Filter string is dependant on the object that implements the IBindingListView.

As you are using a DataSet as the source it means you are actually binding against a DataView that is attached to a specific DataTable from the DataSet. Looking at MSDN for the DataView.RowFilter property there seems no ability to filter against the row count.

So in short, the answer is no, you cannot do as you need. To get around this you could creaet your own filtering class that sits between the DataView and the DataTable and restricts the rows it exposes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜