...

View Full Version : Repeater control HeaderTemplate not working



chelvis
12-15-2006, 06:09 PM
I created a repeater control. I added the following in the header template. But its not displaying the data from database.

But if I put the same thing in itemtemplate, then it works.

Why? The reason I put this in header is I dont want it to repeat. want to display once.


<tr>
<td valign="top" colspan="3"><a class="header">Product Values for <%# DataBinder.Eval (Container.DataItem, "model" ) %></a></td>
</tr>
<tr>
<td height="20" colspan="3"><img src="_spacer.gif" /></td>
</tr>

Grant Palin
12-15-2006, 06:31 PM
I have tinkered with the Repeater control before; one of the things I found out is that the data binding is only done in the ItemTemplate, not the HeaderTemplate. The HeaderTemplate is really just for a static header, not information coming from the bound data source.

Hmm. So you do not want it to repeat...why use a Repeater at all then?

chelvis
12-15-2006, 07:41 PM
Thanks Grant Palin. Thats what I thought so.

I am using other things in the itemTemplate which is actually repeating. But this header shouldnt repeat. So I just added this in a <td> tag outside the repeater control and used a datareader to get the value and assigned to the label control. Its working now.

Grant Palin
12-16-2006, 07:30 PM
Whatever works, I guess. Glad to help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum