user1704677
user1704677

Reputation: 111

DataGridView Not Populating

I've worked with web applications and GridViews, but I am working with a DataGridView for the first time now. I thought it would be pretty much the same thing, but I am having a little trouble trying to get it to fill correctly.

Here is what I currently have:

    familiesBindingSource.DataSource = FamilyLogic.GetFamiliesForView();
    FamiliesGridView.DataSource = familiesBindingSource;

The GetFamiliesView() method returns a DataTable. When I open up this form, nothing happens.

EDIT -- added more code..

    DataTable ds = FamilyLogic.GetFamiliesForView();
    familiesBindingSource.DataSource = ds;

    FamiliesGridView.DataSource = familiesBindingSource;

I could also post the GetFamiliesForView() method, but I am 100% sure it's not in there. It's returning the correct info and the DataSource field of the FamiliesGridView does contain the correct information when I step through it.

Upvotes: 1

Views: 1642

Answers (1)

user1704677
user1704677

Reputation: 111

Welp, I found the issue. I did not realize that I needed these two lines of code.

    FamiliesGridView.Dock = DockStyle.Fill;
    FamiliesGridView.AutoGenerateColumns = true;

Thanks for the help, all.

Upvotes: 1

Related Questions