INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ASP.NET Forum General Use

Name/add a DataGrid column at run time by skittle123
Posted: 17 Feb 04

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

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.



Back to Microsoft: ASP.NET FAQ Index
Back to Microsoft: ASP.NET Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close