Let’s say that I have a form which runs a stored procedure.
This stored procedure creates some rows in a table with pre-generated values and returns me a DataTable containing the rows created by this stored procedure.
On the form, I need to display this information on 3 different DataGridViews, so the user can change it.
The schema is the same but each of the DataGridViews will display different categories and hence hide some irrelevant columns in each of the DataGridView, but in the database, they are all part of the same table.
New rows may be added by the user on all 3 DataGridViews.
I am a bit confused how to display the information from a single DataTable into three different DataGridViews and still have an easy way to update the database with the changes made by the user to the DataGridViews.
I assume that I could break my main DataTable in three of them and then bind each DataTable to the relevant DataGridView, but wouldn’t it pose problems when I will want to save the changes (updated and new rows) to the database considering that my changes are spread into 3 DataTables instead of a single one?
Would there be a better way to achieve this rather than splitting the main DataTable in the first place?
Thanks a lot in advance.
All the DataGridViews need their own DataView. The easiest way may be to use separate BindingSource components.
When you state:
You are actually using the default DataView of the Table. You are looking for something like:
And then you can use view1, view2 to control filtering and sorting.