views:

19

answers:

3

Hello,

My project in c# cantains dataGridView and i have a object contain data.

public class Data { public List list {get;set;}

}

the data is init at program start up and the length of list can change. i want to bind the gridView to object that when gridView show each columns in gridview is bound to list in data object like this: if list count = 3 , than i want gridView contains 3 columns - column0 bind to list[0], column01 bind to list[1], and so on.

i think that i need to bind gridView when form is loading , but how can i do this in my code?

Thanks..

A: 

I guess it is ASP.NET because that's the only one having "GridView". The rest have either DataGrid or DataGridView.

Mamta Dalal
A: 

You can try this:

gridview1.DataSource = list; gridview1.DataBind();

Mamta Dalal
A: 

Hello, this is a winForm applcation , your solution is not good for me bacause if i change mt data like this:

public class Data { public List list {get;set;}
                ****public int  numOfElement {get;set;}****

}

if my list count is 3 , i want dataGridView contain 4 columns : 3 for list and 1 for numOfElement in my object Data.

How i do this in my code?

Thank!

liran