This is a migrated thread and some comments may be shown as answers.

Refreshing GridView after Insert

3 Answers 86 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chad Hensley
Top achievements
Rank 1
Chad Hensley asked on 30 Dec 2009, 08:37 AM
I have a gridview that uses outside controls to insert/update/delete rows.

I fill it with a tableadapter.

        private void ManageLocations_Load(object sender, EventArgs e) 
        { 
            this.wISE_LocationsTableAdapter.Fill(this.locations.WISE_Locations); 
 
        } 

I insert/update/delete using custom calls.  The following works fine -- it inserts fine and grid refreshes with inserted record -- but when I close the child form in which it is called, and then reopen the child form, the grid is missing the new record.

        private void InsertLoc() 
        { 
            sh.InsertLoc(txtName.Text, txtZip.Text, string.Empty, string.Empty); 
            this.rgLocations.Rows.Add(txtName.Text, txtZip.Text); 
            this.UpdatePanelInfo(this.rgLocations.CurrentRow); 
        } 

The same thing with the update and delete.  It is like the tableadapter isn't refreshing with the new data.

I am using a SQLCE db, and that db is in my bin folder.

Any ideas on how I can refresh the tableadapter so that the grid always reflects exactly what is in the db?

Thanks

Chad






3 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 30 Dec 2009, 09:20 AM
Hi Chad Hensley,

Are you sure your are committing your changeset to the database after update/insert/delete operations, that is, are you calling AcceptChanges()?

Sincerely yours,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chad Hensley
Top achievements
Rank 1
answered on 30 Dec 2009, 03:51 PM
I don't use the TableAdapter to do insert/update/delete.  I use a middle tier that updates the db on button click.

Where would I do acceptchanges?


0
Jack
Telerik team
answered on 30 Dec 2009, 04:00 PM
Hi Chad,

I see that you are using a TableAdapter to wrap your data source. In this case you should call its Update method when closing the form. You can find more information in the following MSDN article.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Chad Hensley
Top achievements
Rank 1
Answers by
Victor
Telerik team
Chad Hensley
Top achievements
Rank 1
Jack
Telerik team
Share this question
or