473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Format DataGrid Text

How do I format only the Header text (column names) in a DataGrid? Consider the following code snippet:

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="fname" Text=<%# Container.DataItem("FirstName") %> runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Address" DataField="Address" runat="server"/>
<asp:BoundColumn HeaderText="City" DataField="City" runat="server"/>
.............
.............
.............

How do I format (like make it bold or italicize) the Headers "Name","Address" & "City"? I want to format ONLY the Headers, not anything else that the DataGrid displays.

Please note that I am working on Windows 2000 Professional.

Thanks,

Arpan
Nov 18 '05 #1
4 3066
You can create a style in a style sheet and assign it to the datagrid's
headerstyle-cssclass property.

e.g.

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false"
runat="server" HeaderStyle-CssClass="myClassName">

Alternatively you can use the datagrid's various headerstyle- properties.

e.g.

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false"
runat="server" HeaderStyle-Font-Bold="True" HeaderStyle-Font-Italic="True">

HTH

Alan

"Arpan" wrote:
How do I format only the Header text (column names) in a DataGrid? Consider the following code snippet:

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="fname" Text=<%# Container.DataItem("FirstName") %> runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Address" DataField="Address" runat="server"/>
<asp:BoundColumn HeaderText="City" DataField="City" runat="server"/>
.............
.............
.............

How do I format (like make it bold or italicize) the Headers "Name","Address" & "City"? I want to format ONLY the Headers, not anything else that the DataGrid displays.

Please note that I am working on Windows 2000 Professional.

Thanks,

Arpan

Nov 18 '05 #2
Arpan,

DataGrid has a bunch of attributes with the names starting on HeaderStyle-...

Eliyahu

"Arpan" <ar******@hotmail.com> wrote in message news:OJ**************@TK2MSFTNGP11.phx.gbl...
How do I format only the Header text (column names) in a DataGrid? Consider the following code snippet:

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="fname" Text=<%# Container.DataItem("FirstName") %> runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Address" DataField="Address" runat="server"/>
<asp:BoundColumn HeaderText="City" DataField="City" runat="server"/>
............
............
............

How do I format (like make it bold or italicize) the Headers "Name","Address" & "City"? I want to format ONLY the Headers, not anything else that the DataGrid displays.

Please note that I am working on Windows 2000 Professional.

Thanks,

Arpan
Nov 18 '05 #3
Use the HeaderStyle property. E.g.:

<asp:DataGrid ID='xx' Runat=server>
....
<HeaderStyle Font-Bold=True Font-Name='Arial'></HeaderStyle>
....
</asp:DataGrid>

"Arpan" <ar******@hotmail.com> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
How do I format only the Header text (column names) in a DataGrid? Consider
the following code snippet:

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="fname" Text=<%# Container.DataItem("FirstName") %>
runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Address" DataField="Address" runat="server"/>
<asp:BoundColumn HeaderText="City" DataField="City" runat="server"/>
.............
.............
.............

How do I format (like make it bold or italicize) the Headers
"Name","Address" & "City"? I want to format ONLY the Headers, not anything
else that the DataGrid displays.

Please note that I am working on Windows 2000 Professional.

Thanks,

Arpan
Nov 18 '05 #4
Thanks, Alan, for your suggestion. Thanks to Eliyahu & Shiva as well!
Regards,

Arpan
"Alan Lambert" <Al*********@discussions.microsoft.com> wrote in message news:E9**********************************@microsof t.com...
You can create a style in a style sheet and assign it to the datagrid's
headerstyle-cssclass property.

e.g.

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false"
runat="server" HeaderStyle-CssClass="myClassName">

Alternatively you can use the datagrid's various headerstyle- properties.

e.g.

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false"
runat="server" HeaderStyle-Font-Bold="True" HeaderStyle-Font-Italic="True">

HTH

Alan

"Arpan" wrote:
How do I format only the Header text (column names) in a DataGrid? Consider the following code snippet:

<asp:DataGrid id="myDataGrid" GridLines="both" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="fname" Text=<%# Container.DataItem("FirstName") %> runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="Address" DataField="Address" runat="server"/>
<asp:BoundColumn HeaderText="City" DataField="City" runat="server"/>
.............
.............
.............

How do I format (like make it bold or italicize) the Headers "Name","Address" & "City"? I want to format ONLY the Headers, not anything else that the DataGrid displays.

Please note that I am working on Windows 2000 Professional.

Thanks,

Arpan

Nov 18 '05 #5

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

Similar topics

2
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you...
7
by: Eddy Soeparmin | last post by:
Hi, I need to display a DateTime field in 'mm/dd/yyyy' in a DataGrid.. On myGrid1 - Properties - Columns - myColumn1 - Text format string: I tried to put 'mm/dd/yyyy' in there and it displays...
1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date...
6
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The...
1
by: Julius Fenata | last post by:
Dear all, I need help to change my item-template value format... Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the grid displayed, my 'SubjectPrice' field displayed...
0
by: Buho | last post by:
Hi everybody, I have a question/problem about the .net datagrid, the deal is use it loading detail data of a voucher, so i have 2 instances: first is when i load a document header and lots of...
2
by: Derek Vincent | last post by:
What must I do to overcome a problem with my dates becoming formatted as "2/22/2525 12:00:00 AM" in the datagrid? I want to handle all dates as short string of format "2/22/2525." Otherwise when I...
9
by: seep | last post by:
hi i m finding following error on the code that i wants to use to get all record from table via store procedure with paging. the error is : Input string was not in a correct...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.