Reputation: 583
I have seen lots of examples on how to do this and I can do it but it displays the wrong data set. My issue is that I have a switch board and pass a paramater to another form using this code:
public void LoadCaseNumberKey(String CaseNumberKey)
{
propertyInformationTableAdapter1.FillByCaseNumberKey(newCityCollectionDataSet.PropertyInformation, CaseNumberKey);
muniLiensTableAdapter.FillByCaseNumberKey(newCityCollectionDataSet.MuniLiens, CaseNumberKey);
documentsTableAdapter.FillByCaseNumberKey(newCityCollectionDataSet.Documents, CaseNumberKey);
}
So if I do choose to use one of the many ideas in this http://social.msdn.microsoft.com/Forums/en/winformsdatacontrols/thread/18a9762e-ac67-48a7-a372-55307fe344f3 I get the wrong data as it refreshes the table adapter with the entire dataset.
The code I use to add a record is as follows:
private void cmdAdd_Click(object sender, EventArgs e)
{
DataClasses1DataContext db = new DataClasses1DataContext();
MuniLien newlien = new MuniLien();
newlien.CaseNumberKey = caseNumberKeyTextBox.Text;
db.MuniLiens.InsertOnSubmit(newlien);
db.SubmitChanges();
this.muniLiensDataGridView.EndEdit();
this.muniLiensDataGridView.Refresh();
}
What would be the best way to refresh the datagridview? This is the code that refreshes it but with the entire dataset as opposed to the correct set:
this.muniLiensTableAdapter.Fill(this.CityDataSet.muniLiens);
Any help would be great.
Thanks
Upvotes: 0
Views: 1069
Reputation: 2204
Just call again your method of loading data on datagridview.
e.g:
private void LoadCaseNumberKey(String CaseNumberKey)
{//do your stuff loading to datagrid }
private void cmdAdd_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext();
MuniLien newlien = new MuniLien();
newlien.CaseNumberKey = caseNumberKeyTextBox.Text;
db.MuniLiens.InsertOnSubmit(newlien);
db.SubmitChanges();
this.muniLiensDataGridView.EndEdit();
this.muniLiensDataGridView.Refresh();
// add this if it is the way you bind datagrid -->> LoadCaseNumberKey(String CaseNumberKey)
or
//LoadData();
}
Regards
Upvotes: 1