Formatting a DataGrid header?

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>
 
S

Shimon Sim

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

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top