Hiding the first item of an ASP.NET Repeater causes error: not a valid identifier

sd4ksb

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
Tim Schmelter

Update A control ID is valid only if you use:

  • combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

repeater item command in asp.net

From Dev

ASP.NET Converting repeater item to the textbox

From Dev

ASP.NET repeater only renders the first item in my XML data source

From Dev

jQuery is not finding Asp.net repeater alternating item

From Dev

ASP.NET Repeater Item add divider after each row

From Dev

casting error on binding dictionary to repeater asp.net

From Dev

casting error on binding dictionary to repeater asp.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

NavigateUrl on Repeater ASP.net

From Dev

ACF Add Class if first item in repeater array

From Dev

Asp Repeater Newline in constant error

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

From Dev

Delete an item from an asp:Repeater using jQuery

From Dev

asp.net Repeater Button does not fire event on first page load but after postback it does

From Dev

Binding binary field to ASP.NET DataGrid Causes Error

From Dev

Valid SQL Statement Returning 'Syntax Error" in Asp.NET

From Dev

Error in ASP.net : BC30037: Character is not valid

From Dev

Valid SQL Statement Returning 'Syntax Error" in Asp.NET

From Dev

Specified cast is not valid error using asp.net?

From Dev

syntax error 'from' identifier is not valid input at this position

From Dev

ASP.NET Repeater - Eval() for bool?

From Dev

Convert Bootstrap Carousel to ASP.Net Repeater

From Dev

ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

From Dev

asp.net repeater for each row

From Dev

to disable a label of repeater on some condition in asp .net

From Dev

Using Bootstrap tabs with ASP NET repeater

From Dev

asp.net repeater use template in javascript

From Dev

To bind images in repeater using asp.net

Related Related

  1. 1

    repeater item command in asp.net

  2. 2

    ASP.NET Converting repeater item to the textbox

  3. 3

    ASP.NET repeater only renders the first item in my XML data source

  4. 4

    jQuery is not finding Asp.net repeater alternating item

  5. 5

    ASP.NET Repeater Item add divider after each row

  6. 6

    casting error on binding dictionary to repeater asp.net

  7. 7

    casting error on binding dictionary to repeater asp.net

  8. 8

    NavigateUrl on Repeater ASP.net

  9. 9

    NavigateUrl on Repeater ASP.net

  10. 10

    ACF Add Class if first item in repeater array

  11. 11

    Asp Repeater Newline in constant error

  12. 12

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  13. 13

    Is there an ASP.NET databindable control (like Repeater), which only expects a single item?

  14. 14

    Delete an item from an asp:Repeater using jQuery

  15. 15

    asp.net Repeater Button does not fire event on first page load but after postback it does

  16. 16

    Binding binary field to ASP.NET DataGrid Causes Error

  17. 17

    Valid SQL Statement Returning 'Syntax Error" in Asp.NET

  18. 18

    Error in ASP.net : BC30037: Character is not valid

  19. 19

    Valid SQL Statement Returning 'Syntax Error" in Asp.NET

  20. 20

    Specified cast is not valid error using asp.net?

  21. 21

    syntax error 'from' identifier is not valid input at this position

  22. 22

    ASP.NET Repeater - Eval() for bool?

  23. 23

    Convert Bootstrap Carousel to ASP.Net Repeater

  24. 24

    ASP .NET Using a Repeater inside of UpdatePanel with UpdateProgress

  25. 25

    asp.net repeater for each row

  26. 26

    to disable a label of repeater on some condition in asp .net

  27. 27

    Using Bootstrap tabs with ASP NET repeater

  28. 28

    asp.net repeater use template in javascript

  29. 29

    To bind images in repeater using asp.net

HotTag

Archive