Click here to Skip to main content
15,881,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

i am trying to load a table in a datagridview when i click a button.

This is my code:


C#
private void btn_klant_Click(object sender, EventArgs e)
{

    dgv_main.DataSource = dataset_tables_all1;
    this.klantTableAdapter1.Fill(this.dataset_tables_all1.Klant);
    dgv_main.Refresh();

}


What am i doing wrong?

Thanks.
Posted

you are providing datasource to the table before binding the data change sequence of 1st and 2nd line I think this will work
 
Share this answer
 
Thanks, This is my code now:

C#
private void btn_klant_Click(object sender, EventArgs e)
{

    dgv_main.DataSource = klantBindingSource;
    this.klantTableAdapter1.Fill(this.ds_klant.Klant);
    dgv_main.Refresh();
}


It works!
 
Share this answer
 

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