473,503 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting a DataGrid header?

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>
Apr 3 '06 #1
1 1240
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.

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
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>

Apr 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1490
by: Josh Harris | last post by:
Here is my issue: I have a datagrid that is populated with a datatable. I want the columns of the datagrid to be sortable. I also want to format the numeric columns such as two decimal places...
7
4665
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
4
1695
by: sumit | last post by:
Hi, I want to make a datagrid to be scrollable instead of paging in it. So i have put that datagrid html tags inside <div></div> tags and made that div scrollable. Due to this if i scroll down...
1
1290
by: Ed | last post by:
Hi, I would like to build a datagrid with many columns, but one of them should be a big column with a "Note" field, so I want to write a row with many columns and the next row should have just...
2
1205
by: Amadelle | last post by:
I am using datagrid with templatecolumns. for the life of me I can't figure out how to make the header row a different color than the rest of the tbl. in the datagrid. Ok let me rephrase that. I...
4
3220
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
1
1681
by: Michael Calvin | last post by:
Some basic things I cannot figure out how to do with new datagrid. 1) How do I control the formatting of the column header separately from the rest of the column? 2) If I align right the...
3
1079
Sakalicek
by: Sakalicek | last post by:
Hi all. I have Datagrid in my aspx page and with simple Header. The sorting is enable. I have problem with column's headers formatting. I specified the CssClass for Header not to have the text...
2
6560
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7006
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.