We help IT Professionals succeed at work.

header needs to repeat for each row in datalist

sl1nger
sl1nger asked
on
I have a datalist that works fine, but I want the header to repeat for each row.

<div id="chks">
   <asp:datalist  id="datalist1"
    runat="server"
    RepeatColumns="2"
    RepeatDirection="Horizontal"
    RepeatLayout="table">

what I get...
header: col1, col2, col3, col4
             col1, col2, col3, col4

what I want....
header1: col1, col2, col3, col4
header2: col1, col2, col3, col4

Any suggestions?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
You have to include the header in your datalist.

For better assistance, please include the aspx code of your datalist (and not the asp.cs code)
Commented:
I had to add a ItemDataBound to get this to work, but when I added the header to the datalist.. this broke...

    Protected Sub datalist1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles datalist1.ItemDataBound
        Static count As Integer
        count += 1

        If e.Item.FindControl("lblResults") IsNot Nothing Then
            If count = 3 Then
                CType(e.Item.FindControl("lblResults"), Label).Visible = False
            End If
        End If



    End Sub

Author

Commented:
I'm not getting an error I think it's just looking at the first template, which is now headertemplate, instead of the itemtemplate.   The itemtemplate is the one holding the lblResults
CERTIFIED EXPERT

Commented:
Can you put your aspx code?
sl1inger, did you resolve this? I'm trying to do the same thing

Author

Commented:
Yes, I was able to write it back thru the databoud peice

Explore More ContentExplore courses, solutions, and other research materials related to this topic.