Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB.NET datagrid
Message
From
13/12/2001 15:45:34
 
 
To
13/12/2001 13:27:26
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00593964
Message ID:
00594064
Views:
36
Randy,

>I would like to change the column sizes and column header captions on a datagrid. In the help file, it says that actual columns are not created when the grid is binded to a datasource. I have tried adding a DataGridTableStyle, but my data doesn't appear in the grid and instead of putting the column headers in the header it puts them in a grid column and underlines it and if I click on it I get an error. Anyway can you give me a complete list of steps on how to alter the grid columns and header captions. Thanks in advance and thanks for the quick response on my first problem!

I have not played with this much yet, but a quick look in a reference book indicates you need to specify the columns individually, which can be done with various Column objects:

First, in the DataGrid tag, set the AutoGenerateColumns attribute to false:
< asp:DataGrid
id="whatever"
runat="server"
AutoGenerateColumns="False"
...
>
Specify the columns with BoundColumn objects:
< asp:BoundColumn
DataField="CompanyName"
HeaderText="Whatever you want"
HeaderStyle-BackColor="maroon"
/>
< asp:BoundColumn
...etc
Or, for the ultimate control, use the TemplateColumn object instead of the BoundColumn object, which allows you to specify the HeaderTemplate, FooterTemplate, ItemTemplate (containing a DataBinder evaluation) and EditItemTemplate.

The template controls look really cool and fully flexible, allowing you to define the exact HTML that appears in each column, but are too complex for me to explain here (limited time today). Search help and code sample sites for TemplateColumn and you should find what you need.
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform