I'm new in web developing and i'm kind of having a problem with hiding the first row of a Repeater
. i know that this is kind of a simple problem but i dont know what is wrong with my codes. I have found a lot of articles and some forums with same problem but it just wont work with my code.
Im encountering this error: 'div1-row' is not a valid identifier.
Please help and thank you in advance.
<div id="div1">
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<div id="div1-row" class="div1-row" runat="server">
<div class="div1-class">
<%# CType(Container.DataItem, System.Data.DataRowView).Item("Mfg").ToString%>
</div>
<div class="div1-class">
<%# CType(Container.DataItem, System.Data.DataRowView).Item("Qty").ToString%>
</div>
<div class="div1-class">
<%# CType(Container.DataItem, System.Data.DataRowView).Item("Availability").ToString%>
</div>
<div class="div1-class">
<%# CType(Container.DataItem, System.Data.DataRowView).Item("QtyRange").ToString%>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
Protected Sub Repeater1_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If e.Item.ItemIndex = 0 Then
e.Item.FindControl("div1-row").Visible = False
End If
End Sub
Update A control ID
is valid only if you use:
So ID="div1-row"
is not allowed, use ID="div1_row"
instead.
Old answer:
Why don't you make the complete first RepeaterItem
invisble?
Protected Sub Repeater1_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
e.Item.Visible = e.Item.ItemIndex <> 0
End Sub
Note that the ItemIndex
property only applies to data items in the Repeater
control. The ItemType
property must be set to ListItemType.Item
, ListItemType.AlternatingItem
, ListItemType.SelectedItem
, or ListItemType.EditItem
.
So it works for example not for the Header
if you use a HeaderTemplate
.