Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    406
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Repeater control HeaderTemplate not working

    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.

    Code:
    <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>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    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?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    406
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    Whatever works, I guess. Glad to help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •