How to refresh a datagrid in C# windows application after delete/insert/updation of records
It is related to Datagrid in C# windows Applications:
1. When a row is deleted from a datagrid, it should be removed from the grid as well as from the database.It gets deleted from database but still visible on datagrid. I used datagrid.refresh but it did not work?
How to do it?
Basically how to refresh a datagrid after insertion/deletion/updation of records
2. When I try to navigate the records in datagrid after deletion/addition/updation of row, I get the following error message:
"An Unhandled exception has occured in your application..........
Cannot Create a child list for field Test"
Why it is so. I am writing the code below:
Under Form_load event:
cc=new Class1();
string ss="select * from test";
dt=cc.conn(ss); //dt is dataset
dataGrid1.SetDataBinding(dt,"Test");
this.BindingContext[dt,"Test"].Position=0;
under adding of new record:
tring ins="Insert into test values("+aa+","+"'"+ss+"')";
dt=cc.conn(ins);
dt.AcceptChanges();
MessageBox.Show("record added successfully");
Under Next record navigation:
this.BindingContext[dt,"Test"].Position+=1;
Under Previuos record navigation:
this.BindingContext[dt,"Test"].Position-=1;
How to handle this error?