473,323 Members | 1,551 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,323 software developers and data experts.

in headertemplate asp label does not work

Hi

In my headertemplate I do not get the column like in the itemtemplate ( I am
using the northwind db):
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 24px; POSITION:
absolute; TOP: 24px" runat="server"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
BackColor="White" CellPadding="3"
GridLines="Vertical" ForeColor="Black" Height="224px"
AutoGenerateColumns="False" Width="536px">
<FooterStyle BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#000099"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#CCCCCC"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="Black"
Height="200"></HeaderStyle>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999"></PagerStyle>
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
Customerid:
<asp:Label ID=test Runat=server text='<%#
DataBinder.Eval(Container.DataItem, "customerid") %>'>
</asp:Label>
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "customerid") %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

what could be wrong?

ch Jim
Nov 19 '05 #1
1 1517
Jimmy:
No data is bound to the header template row. I guess you are thinking that
the first row in your datasource will show up in the HeaderTemplate, that
just isn't so. The headertemplate is typically used to show headers, such as
"Customer Id" and "First Name" and then the itemTemplate used to show the
data. If you want the first row of data to look really different, you'll
need to hook into the OnItemDataBound event, IF to see if it's the first
row, and if so, apply special formatting.
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Jimmy" <be****@gmail.com> wrote in message
news:OL**************@TK2MSFTNGP14.phx.gbl...
Hi

In my headertemplate I do not get the column like in the itemtemplate ( I
am
using the northwind db):
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 24px; POSITION:
absolute; TOP: 24px" runat="server"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
BackColor="White" CellPadding="3"
GridLines="Vertical" ForeColor="Black" Height="224px"
AutoGenerateColumns="False" Width="536px">
<FooterStyle BackColor="#CCCCCC"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#000099"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#CCCCCC"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="Black"
Height="200"></HeaderStyle>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999"></PagerStyle>
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
Customerid:
<asp:Label ID=test Runat=server text='<%#
DataBinder.Eval(Container.DataItem, "customerid") %>'>
</asp:Label>
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "customerid") %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

what could be wrong?

ch Jim

Nov 19 '05 #2

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

Similar topics

1
by: SamIAm | last post by:
Hi I have a DataGrid called dgTraders 1 of the columns is a template column and this column has a Dropdown box in its HeaderTemplate section. The Dropdown box is called selCities. How do I...
1
by: Cheng | last post by:
hi i have adding a label in the headertemplate of a datagrid i have write the code to find it; //my code Label lbl = (Label) DataGrid1.FindControl("myLabel"); but i can't find it what is...
5
by: Yan Wang | last post by:
Hi! Does anyone know how to get the text in textbox field which is in HeaderTemplate of a DataGrid? In the following code, I can not get text of "tbName". I typed something in that box. I can...
1
by: CJM | last post by:
I've copied (& modified) some code from MSDN which uses a Repeater control, but I'm getting an error: Unexpected end of file looking for </HeaderTemplate> As far as I can see I've not made an...
2
by: Mick | last post by:
Hi, just wanna know if it's possible to get access to my several label controls of my repeater's headertemplate in order to set their Text property ? Thks for help-
2
by: Andy | last post by:
Hi, This is one of those things I thought should e easy... I'm programatically trying to set the navigateURL property in a hyperlink in the headertemplate of a repeater, but always get the...
2
by: jobs at webdos | last post by:
I have data that looks like this prodid fileid date where prodid repeats I want report like this prodid - fileid date
1
by: =?Utf-8?B?SmliZXkgSmFjb2I=?= | last post by:
Hi: I placed an <asp:Tableinside the HeaderTemplate of a TemplateField of a GridView. The contents of the <asp:Table just doesn't show up. Can someone please tell me why? Thanks, Jibey
1
by: Andy B | last post by:
How do you use css classes with acordion HeaderTemplate? I am trying to change the background color of its HeaderTemplate and can't figure out how.
0
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...
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...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.