How to position to row in DataView or DataTable

M

magreenb

Is it possible to position to a specific row in a DataTable or DataView? I
have a DataGrid that displays either a detail view or a summary view and
uses built-in paging. Both sets of data are from the same database table,
the summary view is an aggregate (group by) with one less column than the
detail view.

When the user changes views, I execute the appropriate stored procedure and
re-bind the results to the grid. The problem is I need to re-display the
same page of records in the new view. In other words, if the record for
company ABC was the first record displayed in the grid in one view, it needs
to be the first record in the other view as well. Currently if the user has
paged down to page 3 and changes views, they are back on page 1.

Thanks for you help,

Mark
 
R

Rami Saad

Hello,

Yes you can position to a specific row, and get the needed information from
it as well.
You can start by choosing a row, or array of data rows from the data table
with the following:
DataRow row=myDataTable.Select(FilterString);
where filter string can be an SQL statement to retrieve the needed row(s).
Once you get the row, you can obtain information from it using the
following:
row.ItemArray[myDataTable.Columns[ColumnName].toString()];

Hope this helps you answer your question.
If you need more help regarding this issue, please don't hesitate to
post/reply back.

Regards,
Rami Saad
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top