Displaying only certain results in a DataGrid

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

Hi all, Iv got a slight problem with a datagrid and the ability to only
display certain things in it.



I have a Data grid which is connected to a data table.



The data table is connected to a data set which in turn gets its info from
an xml file and xml schema.



I am able to view all results in the data grid and modify them and then save
them back to the xml file.



However I want to be able to only display certain results in the data grid
(e.g. those that only match a certain ID).



I am aware that you can run a query on the Data table and then use that to
populate the data grid. However if I did this any changes that were made on
the datagrid would not be made back to the data table (I assume).



Is there any way I can still keep the link between the datagrid and the data
table and only display certain rows that match a certain ID while still
allowing the user to edit these results?



Many thanks for reading this and for any help that can go with it.



Scott.
 
Scott,

This should be easy. Basically, you can filter the DataTable using a
DataView. Once you do that, bind it to the grid, and only the filtered
results will be shown. Additionally, when you make changes, it will be
persisted back to the data table, at which point, you can save it.

Hope this helps.
 
Thank you for the quick reply, I will look into these data views.


Nicholas Paldino said:
Scott,

This should be easy. Basically, you can filter the DataTable using a
DataView. Once you do that, bind it to the grid, and only the filtered
results will be shown. Additionally, when you make changes, it will be
persisted back to the data table, at which point, you can save it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

scott said:
Hi all, Iv got a slight problem with a datagrid and the ability to only
display certain things in it.



I have a Data grid which is connected to a data table.



The data table is connected to a data set which in turn gets its info from
an xml file and xml schema.



I am able to view all results in the data grid and modify them and then
save
them back to the xml file.



However I want to be able to only display certain results in the data grid
(e.g. those that only match a certain ID).



I am aware that you can run a query on the Data table and then use that to
populate the data grid. However if I did this any changes that were made
on
the datagrid would not be made back to the data table (I assume).



Is there any way I can still keep the link between the datagrid and the
data
table and only display certain rows that match a certain ID while still
allowing the user to edit these results?



Many thanks for reading this and for any help that can go with it.



Scott.
 

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

Back
Top