S
Steve Franks
OK this is driving me nuts - hope someone can help.
I am searching for a way to dynamically output a value within the
HeaderTemplate section of a Repeater control. Is this possible?
It is obvious how to do this in the ItemTemplate section, but how can I do
this in the Header section?
Consider the excerpt I included at the bottom of this message. In this the
DataBinder.Eval is used to dynamically output the ItemTemplate and this
works great.However in the area marked "UNIQUE TITLE HERE" I want to
dynamically write out the value of a particular variable as the title for my
table and I cannot figure out how to do this.
This is especially challenging for me because I created a .ascx file that
contains the header, and then I am using:
Repeater1.HeaderTemplate = Page.LoadTemplate("myheader.ascx");
to load it.
I am doing it this way because my header has a ton of HTML and I need to
output these tables throughout my site, so rather than keep repeating blocks
of the same HeaderTemplate section (except fot the title!) all over the
place, I've used this approach.
If I could figure out a way for the .ascx to access a variable within my
ASP.NET page, then I could just do this in my header template:
<tr><td colspan=2> <% Response.Write(varFromAspNetPage);
%> </td></tr>
Any ideas? Thanks.
<asp:Repeater id=Repeater1 runat="server">
<HeaderTemplate>
<table border=1>
<tr><td colspan=2> UNIQUE TITLE HERE </td></tr>
<tr>
<td><b>Company</b></td>
<td><b>Symbol</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%# DataBinder.Eval(Container.DataItem, "Name") %>
</td>
<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Container.DataItem is NULL when ASP.NET is processing the header, so I do
not know how I can dynamically get a value in to the header!
Thanks,
Steve
I am searching for a way to dynamically output a value within the
HeaderTemplate section of a Repeater control. Is this possible?
It is obvious how to do this in the ItemTemplate section, but how can I do
this in the Header section?
Consider the excerpt I included at the bottom of this message. In this the
DataBinder.Eval is used to dynamically output the ItemTemplate and this
works great.However in the area marked "UNIQUE TITLE HERE" I want to
dynamically write out the value of a particular variable as the title for my
table and I cannot figure out how to do this.
This is especially challenging for me because I created a .ascx file that
contains the header, and then I am using:
Repeater1.HeaderTemplate = Page.LoadTemplate("myheader.ascx");
to load it.
I am doing it this way because my header has a ton of HTML and I need to
output these tables throughout my site, so rather than keep repeating blocks
of the same HeaderTemplate section (except fot the title!) all over the
place, I've used this approach.
If I could figure out a way for the .ascx to access a variable within my
ASP.NET page, then I could just do this in my header template:
<tr><td colspan=2> <% Response.Write(varFromAspNetPage);
%> </td></tr>
Any ideas? Thanks.
<asp:Repeater id=Repeater1 runat="server">
<HeaderTemplate>
<table border=1>
<tr><td colspan=2> UNIQUE TITLE HERE </td></tr>
<tr>
<td><b>Company</b></td>
<td><b>Symbol</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%# DataBinder.Eval(Container.DataItem, "Name") %>
</td>
<td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Container.DataItem is NULL when ASP.NET is processing the header, so I do
not know how I can dynamically get a value in to the header!
Thanks,
Steve