Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    ASP:REPEATER e altri oggetti <asp:

    Ma in un itemtemplate (o header o footer) di un asp:repeater posso inserire altri oggetti asp tipo <asp:label?

    Penso di si ma poi... come ci accedo?

    Se io provo:
    codice:
    <FooterTemplate>
    <table border="0">
    <tr>
    <td>
    <asp:HyperLink runat="server" ID="h_previous" Text="Pagina Precedente" />
    </td>
    <td>
    <asp:HyperLink runat="server" ID="h_following" Text="Pagina Seguente" />
    </td>
    </tr>
    </table>
    </FooterTemplate>
    codice:
        Private Sub BuildPagingMenu(ByVal CurPage As Integer, ByVal PageCount As Integer)
            If CurPage >= PageCount Then
                h_following.text="prova"
            End If
        End Sub
    Ottengo:

    Compiler Error Message: BC30451: Name 'h_following' is not declared.
    Visual Basic e Dintorni
    Blog sullo sviluppo Web in generale

  2. #2
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    :master: sono da tanto che non lo uso, vedi se può andare

    repeater:
    codice:
            <asp:Repeater ID="Repeater1" runat="server">
                <HeaderTemplate>
                    <table border="1">
                        <tr>
                            <th>id</th>
                            <th>testo</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <%#Eval("id")%>
                        </td>
                        <td>
                            <%#Eval("testo") %>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        <tr>
                            <td colspan="2">
                                <table border="0">
                                <tr>
                                <td>
                                <asp:LinkButton runat="server" ID="h_previous" CommandName="previous" Text="Pagina Precedente" />
                                </td>
                                <td>
                                <asp:LinkButton runat="server" ID="h_following" CommandName="following" Text="Pagina Seguente" />
                                </td>
                                </tr>
                                </table>
                            
                            </td>
                        </tr>
                    
                    </table>
                </FooterTemplate>
            </asp:Repeater>
    codice
    codice:
        Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
            'e.CommandSource è l'oggetto che scatena il postback
            Dim o As Object = e.CommandSource()
            If TypeOf o Is LinkButton Then 'sono interessato al linkbutton
                Dim l As LinkButton = DirectCast(e.CommandSource, LinkButton)
                PrintLn(l.ID) 'stampo id
                PrintLn(l.CommandName) 'stampo CommandName
            End If
    
        End Sub
    Pietro

  3. #3
    Capito, come immaginavo quindi non c'è un modo per referenziarlo direttamente...
    devo intercettare l'oggetto che scatena l'azione prendendolo dalla lista dei controlli del repeater.

    ti ringrazio.
    Visual Basic e Dintorni
    Blog sullo sviluppo Web in generale

  4. #4
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    un altro modo è questo
    codice:
        Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
            Select Case e.Item.ItemType
                Case ListItemType.Footer
                    Dim l As LinkButton = DirectCast(e.Item.FindControl("h_previous"), LinkButton)
                    If (l IsNot Nothing) Then
                        AddHandler l.Click, AddressOf h_previous_click
                    End If
    
            End Select
    
        End Sub
    
        Private Sub h_previous_click(ByVal sender As Object, ByVal e As EventArgs)
            Dim l As LinkButton = DirectCast(sender, LinkButton)
            PrintLn(l.CommandName)
        End Sub
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.