Home All Groups Group Topic Archive Search About

Add header text dynamically in a datagrid with templatecolumns?

Author
15 Feb 2005 6:43 PM
SK
Hello,

    I have a dg, which uses templatecolumns. Now I would
like to assing the header text of these columns, with the
names I have in my dataset. But I dont get how to do that.
Here is my dg:

<asp:datagrid id="dg" ... AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
  <ItemTemplate>
  <%#container.dataitem("somevalue")%>
  </ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

thanks for any suggestion.

Author
15 Feb 2005 8:17 PM
Elton Wang
Try

dg.Columns[index].HeaderText = HeaderName;

HTH,

Elton Wang
elton_w***@hotmail.com


Show quoteHide quote
>-----Original Message-----
>Hello,
>
>    I have a dg, which uses templatecolumns. Now I would
>like to assing the header text of these columns, with the
>names I have in my dataset. But I dont get how to do
that.
>Here is my dg:
>
><asp:datagrid id="dg" ... AutoGenerateColumns="False">
><Columns>
><asp:TemplateColumn>
>  <ItemTemplate>
>  <%#container.dataitem("somevalue")%>
>  </ItemTemplate>
></asp:TemplateColumn>
></Columns>
></asp:datagrid>
>
>thanks for any suggestion.
>.
>