Bind Gridview specific column with array object

Posted by vishalneeraj-24503 under LINQ category on | Points: 40 | Views : 879
Write below code for binding Gridview object to array object:-
string[] arr_values = { "value1", "value2", "value3", "value4", "value5" };
grid_data.DataSource = from o in arr_values
select new { your_column_name = o };

Here,your_column_name will be written inside Gridview Bound-Field as
<asp:BoundField DataField="your_column_name" HeaderText="Any Column Name"/>

You can also take List collection to achieve the same.

Comments or Responses

Login to post response