Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   DataGrid Dynamic HeaderText (http://www.velocityreviews.com/forums/t760363-datagrid-dynamic-headertext.html)

Seli 03-03-2004 05:11 PM

DataGrid Dynamic HeaderText
 
Hell

How can I change the headerText of an AutoGenerateColumns DataGrid

myDataGrid.DataSource=ds.Tables["Products"].DefaultView
myDataGrid.DataBind()
myDataGrid.Columns[0].HeaderText="MARCEL";

in the third line I get always an exception. myDataGrid.Colums.count Returns 0!

Thank
Seli

SB 03-03-2004 07:23 PM

Re: DataGrid Dynamic HeaderText
 
Seli,
You can do that in the ItemCreated event.of the DataGrid.
Make sure that you only apply the value when the IteMType is of type header
=>

//I write from scratch, not Iin VS so there might be typo mistakes
if (e.Item.ItemType==ListItemType.HeaderItem){
e.Item[0].HeaderText="MARCEL";
}
Selim

"Seli" <anonymous@discussions.microsoft.com> wrote in message
news:0D61DB9E-6B3A-4247-9955-03315AD1AD78@microsoft.com...
> Hello
>
> How can I change the headerText of an AutoGenerateColumns DataGrid?
>
> myDataGrid.DataSource=ds.Tables["Products"].DefaultView;
> myDataGrid.DataBind();
> myDataGrid.Columns[0].HeaderText="MARCEL";
>
> in the third line I get always an exception. myDataGrid.Colums.count

Returns 0!!
>
> Thanks
> Seli





All times are GMT. The time now is 10:17 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.