Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rebind Datagrid

Status
Not open for further replies.

zatch

MIS
Oct 11, 2001
75
US
Is it completely necessary to update the database and refresh the dataset which the grid is bound to in order to get the datagrid to rebind to the dataset?

sqldataadapter.update(sqldataset)
sqldataadapter.fill(sqldataset)
datagrid.databind

I'd like to make changes only in the dataset itself and then wait to push all changes to the database upon user command. The problem arises when I try to delete a record from the dataset and then rebind without updating/fetching changes to/from the database. The datagrid shows up with only column headings - no data. Thanks for any tips.

Zatch
 
I am not sure what the exact problem is. If you want the users to select a bunch of rows then have one click to update, place a checkbox in a template column of each row. Then let them select the rows to delete, and click an Update button. Loop through all the rows of the grid and call the Update for each row where the checkbox is checked.
 
My thinking is that I don't want to push any changes (edits, adds, deletes) to the database until the user decides they are completely finished manipulating records. I'm trying to avoid a call to the database each time they make a change to the dataset. A simple rebind (datagrid.databind) does not seem to re-format the datagrid well - you have to 1)update the database 2) Refill the dataset 3) .databind to get the grid to refill with correct data.

Thanks for replying.

Zatch
 
My suggestion is doing just that... Edit all rows, select each one to delete, then click a button once and save the changes and rebind the grid.
 
That's a good idea, but I don't think it's practical for this project. The datagrid has the same behavior when adding records.

Thanks again.

Zatch
 
This article describes exactly what you need to do in order to create a local dataset which can be then be used to update the database whenever is necessary:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top