Datagridview doesnt show any data

50 views Asked by At

I am using a binding source control to load a datagridview in the winforms application. I load the binding source control with a list and the binding source as the datasource for the datagridview. when I run the code there is no data loaded in the datagridview. can anyone help me ? The code I wrote for this is given below.`

 private void SetData(ListAirport la, string iata)
    {
        itemBindingSource.DataSource = la;

        dgvItemDetails.DataSource = itemBindingSource;
    }

The Interesting thing is that, when I take itemBindingSource.Count, it shows 556 and dgvItemDetails.Rows.Count as 0

2

There are 2 answers

0
Forklift On

Your DataGridView does not seem to know how to bind to a ListAirport. What you want to do is convert that to a DataTable.

3
Sean T On

Use this:

    dgvItemDetails.DataSource = itemBindingSource;
    dgvItemDetails.DataBind();//You need to bind it to the control