Formatting a DataGrid header?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm trying to use templated columns to format the header for my datagrid.
Can I use the HeaderTemplate to make the "My Title Goes.." text to span
across the entire datagrid table when it's generated? Or some other method?
Thanks.

<asp:DataGrid ID="dgList" AutoGenerateColumns=False Runat=server>
<Columns>
<asp:TemplateColumn >
<HeaderTemplate>My Title Goes Here.</HeaderTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Id") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "CompanyName") %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
 
If you want just to create one line header use Caption property.
If your header must be more complicated you have to use repeater or DataList
controls.
Hope helps.
Shimon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top