What data object should I use with a DataGrid

  • Thread starter Thread starter William Gower
  • Start date Start date
W

William Gower

I am creating a page that will use a DataGrid. It will display a list of
people. Each row will have an Edit button that will take the user to
another page where they can edit that particular record. Each row will also
have a Delete button that will delete the record. Should I use a DataSet as
the datasource of the Grid?
 
If this is a web app, a dataset is a good choice. If you don't have multiple
tables, then a datatable will work just as well. Moreover, if you use a
DataView, based on the datatable, you can implement sorting and filtering
without having go make trips back to the db.

I think either way you want a disconnected object (one of the above) even
though you can use a datareader (dataGrid.DataSource =
myCommand.ExecuteReader();) because you want to use it do edit and you can
save the object (Dataset/datatable/dataview) in session state, and just call
the update command of your dataadpater when you are done editing.
Definitely think this is the most straightforward approach and depending on
things like sorting and filtering, probably the most efficient too.

Cheers,

Bill
 
Back
Top