how to rebind my datagridview from database in c#?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Bryian TanRank #396 · 6.3K reputationPosted Aug 25, 2010, 3:56 PM EDT
The same way you bind the datagridview at the beginning (page load/ button click).
myDataGrid.DataSource = myDataSource;
myDataGrid.DataBind();
aamer ah4 reputationPosted Aug 28, 2010, 12:48 AM EDT
first thank you for your answer,
but the .DataBind() not found!!
i try to write this function and it's not found!!
Sam HobbsRank #107 · 20.5K reputationPosted Aug 28, 2010, 8:06 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Aug 28, 2010, 8:07 PM EDT
Bryian TanRank #396 · 6.3K reputationPosted Aug 29, 2010, 4:13 PM EDT
Sorry, I was wrong, there is no DataBind() method with the Window DataGridView control. I'm not sure how you structure your application. Try to rebind it again in code behind
bindingSource1.DataSource = myDataSource;
dataGridView1.DataSource = bindingSource1;
or you can try use the Fill method of the TableAdapter object to reload the data into the DataSet Object.
this.YourTableAdapter.Fill(this.YourDatabaseDataSet.YourTable);