473,666 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic header output in Repeater control?

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.Heade rTemplate = Page.LoadTempla te("myheader.as cx");
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( varFromAspNetPa ge);
%> </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>Compan y</b></td>
<td><b>Symbol </b></td>
</tr>

</HeaderTemplate>

<ItemTemplate >

<tr>
<td> <%# DataBinder.Eval (Container.Data Item, "Name") %>
</td>
<td> <%# DataBinder.Eval (Container.Data Item, "Ticker") %>
</td>
</tr>

</ItemTemplate>

<FooterTemplate >

</table>

</FooterTemplate>

</asp:Repeater>

Container.DataI tem 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
Nov 19 '05 #1
1 4649
Any reason you don't put the Repeater into a UserControl, rather than
trying to stuff a UserControl into your Repeater? And why does it
matter to you that your code goes into the HeaderTemplate at all? Why
not just drop any HTML to open your table structure in front of the
Repeater, then close the table outside the Repeater?

I've been using Repeaters for years, and have never come across a good
reason to bother with HeaderTemplate and FooterTemplate. What exactly
are you trying to accomplish that requires you to use them?

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #2

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

Similar topics

1
3572
by: Steve Gadlin | last post by:
Hi there! First off, let me apologize for the basic question... I'm very new to .NET programming. I'm building a web site using VB.NET, and am trying to include several custom user controls. One of these user controls handles the navigation. This user control polls the database for the section headers that the current user has access to. It grabs those headers from the database, let's say 5 of them, then
2
5308
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted user controls. Worse I'm trying to add dynamic user controls from within a repeater loop (looping through attributes)... I bind to a function in the code behind and pass in the attribute. <asp:repeater id="rAttributes" Runat="server">
0
1628
by: Pat Sagaser via .NET 247 | last post by:
I'm using a repeater with a dynamic template. I don't know the fields to display (or how many) until runtime. I have everything working except for linking Button events to the repeaters ItemCommand (see below). I've found plenty of examples for doing it using <ItemTemplate> in the aspx file, but I'm stumped when it comes to doing it dynamically at run time. /////////////////////////// .apsx file: <%@ Page language="c#"...
0
1993
by: Pat Sagaser via .NET 247 | last post by:
I'm trying to add LinkButtons to a Repeater control using adynamic template. The docs state that you should be able tobubble the click event to the containing Repeater. There areplenty of examples in the documentation for doing this using an<ItemTemplate> tag, but I haven't found any indication for howyou would do this in a dynamic template (implementing theITemplate interface). I'm adding the LInkButton in the TemplateDataBinding...
7
2999
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
1
16942
by: Mr Not So Know It All | last post by:
i found this code to create dynamic itemtemplates on the microsoft site. here's the url: Creating Web Server Control Templates Programmatically http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingwebservercontroltemplatesprogrammatically.asp here's the code I'm using.. public void InstantiateIn(System.Web.UI.Control container) {
5
4077
by: Mr Not So Know It All | last post by:
i was able to add the table via the codebehind to the repeater (itemtemplate). the key was to add it to the container. however, now, the data is repeating itself in each row. can someone help me understand how the repeater works? thx in advance. <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>MyTable</title> </head> <body>
0
5279
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all the days in the week with dates and textboxes to fill in some data. row 1: question
3
2105
by: s.bussing | last post by:
Hi, I have been reading for hours now, but I'm still not able to solve my problem, though a lot of people are struggling with something similar. On my page I have a nested repeater. In the inner repeater for each item a usercontrol is added which has a textbox and two buttons. No I know that when the page is posted back (in my case by pushing one of the buttons of the control), I have to recreate all the dynamic control. I want to...
0
8363
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8645
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
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 we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.