• User •

    Problemi con Repeater

    Ciao

    ho bisogno di un piccolo aiutino a correggere il codice che ho scritto........
    ho provato in vari modi ma non mi riesce....

    Mi dà errore nella pagina aspx:
    'DataBinding: 'System.Data.DataRowView' non contiene una proprietà con nome 'Immagine'.'

    vi posto tutto il codice:

    <asp:Repeater ID="MyRepeater" runat="server">
             
             
             
             <ItemTemplate>
              <tr>
             <td width="65" height="78" align="center" valign="middle" class="row_bord" ><%#DataBinder.Eval(Container.DataItem, "Immagine")%></td>
             <td width="820" class="row_bord"><table width="816" border="0">
                  <tr>
                    <td width="58" class="galleria">Nome: </td>
                    <td width="270" class="galleria2"><%#DataBinder.Eval(Container.DataItem, "Nome")%> </td>
                    <td width="80" class="galleria">Codice:</td>
                    <td width="172" class="galleria2"> <%#DataBinder.Eval(Container.DataItem, "Codice")%></td>
                    <td width="87" class="galleria">Peso : </td>
                    <td width="123" class="galleria2"><%#DataBinder.Eval(Container.DataItem, "Peso")%> </td>
                  </tr>
                  <tr>
                    <td colspan="6" class="galleria2"><%#DataBinder.Eval(Container.DataItem, "Descrizione")%> </td>
                  </tr>
                  <tr>
                    <td colspan="2" class="galleria2">&nbsp;</td>
                    <td class="galleria2"><span class="galleria">Misure: </span></td>
                    <td class="galleria2"><%#DataBinder.Eval(Container.DataItem, "Misure")%> </td>
                    <td class="galleria">Prezzo:</td>
                    <td class="galleria2"><%#DataBinder.Eval(Container.DataItem, "Immagine")%></td>
                  </tr>
                </table>
                </td>
            
              </tr> 
             </table>
             </ItemTemplate>        
                    
                  
              
     </asp:Repeater>
    

    Nel codice richiamo da due storeprocedure i dati e le inserisco in due datatable, poi

     Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim dt As DataTableCollection
            Dim dt1 As DataTableCollection
    
            dt = RicTesti("006", "001")
            dt1 = RicercaProdotti("001", "001")
    
            Bind1(dt(0))
            Bind(dt1(0))
    
    
            MyRepeater.DataSource = dt1.Item(0)
            MyRepeater.DataSource = dt.Item(0)
    
            MyRepeater.DataBind()
    
    
    
        End Sub
    
        Private Sub Bind(ByVal dt1Prodotti800 As DataTable)
    
    
    
    
            For Each row As DataRow In dt1Prodotti800.Rows
    
                row("Immagine") = String.Format("<a href=""{0}""><img src=""images/mobili800/{1}""></a>", row("Collegamento").ToString().Trim(), row("Immagine").ToString().Trim())
            Next
    
        End Sub
    
        Private Sub Bind1(ByVal dtArticoli As DataTable)
    
            For Each row As DataRow In dtArticoli.Rows
                Dim lt As Literal = CType(Panel1.FindControl(Trim(row("CodiceCampo").ToString())), Literal)
                If Not (lt Is Nothing) Then
                    lt.Text = row("Prompt").ToString()
                End If
            Next
    
        End Sub
    

    Vi prego aiutatemi, non riesco a scrivere il codice in maniera corretta...... ❌x:gtsad:


  • User •

    Il problema non sta nel codice, sta nelle storedprocedure, in quanto sembra che non restituiscano un campo chiamato Immagine, che invece tu usi nel repeater.

    Prova ad eseguire manualmente le SP e vedi se ti viene restituito il campo immagine.

    :ciauz:


  • User •

    grazie....
    prova prova ci ero arrivata...........
    effettivameente c'era un errore nella store procedure.