Home
Manage Your Code
Snippet: Programmatically add a bound field to a GridView (C#)
Title: Programmatically add a bound field to a GridView Language: C#
Description: This example takes a DataTable and adds bound fields for every column to a GridView in ASP.Net 2.0 Views: 439
Author: Aaron Crandall Date Added: 8/31/2007
Copy Code  
1foreach (DataColumn column in dataTable.Columns)
2{
3	BoundField field = new BoundField();
4	field.HeaderText = column.Caption;
5	field.DataField = column.ColumnName;
6	grid.Columns.Add(field);
7}