0
votes

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..

2
Is this ASP.NET, Winforms, WPF, or Silverlight? - itchi

2 Answers

0
votes

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

0
votes

You can try this:

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