Bind Gridview specific column with array object

vishalneeraj-24503
Posted by vishalneeraj-24503 under LINQ category on | Points: 40 | Views : 1334
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 };
grid_data.DataBind();

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