Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My datagridview won't save the changes made in it back to the database. I've bound the datagridview to my combobox so that corresponding values appear on it when the selected value is chosen in the combobox. The datagridview is editable but doesn't save the changes made. is there another method to bind the combobox to the datagridview so that changes can be saved? Or is there some code I can use to save the datagridview changes?

C#
private void cboeCID_SelectedIndexChanged_1(object sender, EventArgs e)
       {
           var CID = Convert.ToInt32(cboeCID.Text);

           using (var db = new Entities2())
           {

               var course = from c in db.Student_Course
                            where c.CID == CID
                            select new Class1
                            {
                                SID = c.SID,
                                Mark = c.Mark
                            };
               editDataGridView.DataSource = course.ToList();
               Validate();
               editDataGridView.EndEdit();
               editDataGridView.Update();


           }


What I have tried:

Validate();
editDataGridView.EndEdit();
editDataGridView.Update();
Posted
Comments
[no name] 15-Aug-16 5:22am    
I am not able to get exact scenario. where is combobox, and if you are looking for CRUD operation in gridview check this
http://www.aspdotnet-suresh.com/2015/07/aspnet-gridview-crud-operations-insert-select-edit-update-delete-using-single-stored-procedure-example.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900