Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name/add a DataGrid column at run time

ASP.NET Forum General Use

Name/add a DataGrid column at run time

by  skittle123  Posted    (Edited  )
Hi all.
I was trying to rename a column in a datagrid so I could pull data from different tables but use the same form/datagrid for it.
the only way that I could find to do this was at this link:

http://www.c-sharpcorner.com/Code/2003/Feb/DynamicDataGrid.asp

It describes how to add columns via code at run time... and also some other things.

In short the way to add a column is
// Create ID column & add to DataGrid
BoundColumn col = new BoundColumn();
col.HeaderText="User ID";
col.DataField="ID";
DataGrid1.Columns.Add(col);

Hope this helps answer some questions.


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top