Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically define GridView columns
Message
From
07/07/2006 23:50:06
 
 
To
07/07/2006 16:24:55
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01134578
Message ID:
01134640
Views:
13
Hi, Jerry,

Off the top of my head, I can only think of one thing. You could create a subset datatable with just the columns you want....bind the gridview to the new datatable....and set the gridview "generatecolumns" property to true. It's not a very elegant solution, but it should work.

You can use the new ToTable method in ADO.NET 2.0. For instance, if you had a datatable with 10 columns, and you only want to show 3 of them, you could do something like...
DataTable dtNewTable = dtSourceTable.DefaultView.ToTable(false,"MyColumn1","MyColumn2","MyColumn3");
(The first parm of 'false' is for the option to do the equivalent of a "select distinct")

If I can think of something else, I'll follow up, but that's the only thing that comes to mind.

Kevin
Previous
Reply
Map
View

Click here to load this message in the networking platform