56 messaggi dal 25 settembre 2010
ciao qualcuno sa dove canno il databibding?
scenario:
3 livelli
classe incapsula:
Public Class MerciContent


        Private id_MTipo As Integer
        Private Mdescrizione As String
        Private User_Id As Guid
        Private MDescrizione_Estesa As String

        <DataObjectFieldAttribute(True, True, False)>
        Public Property Id() As Integer
            Get
                Return id_MTipo

            End Get
            Set(value As Integer)
                id_MTipo = value
            End Set
        End Property
<zac>

classe dal
    Public Class MerciologicaDB

        Public Shared Function GetListMerci() As MerciContent
            Dim myCategory As MerciContent = Nothing
            Dim factory As DbProviderFactory = DbProviderFactories.GetFactory(ObjCn.GetProviderName())
            Dim conn As DbConnection = factory.CreateConnection()
            conn.ConnectionString = ObjCn.GetConnectionString()
            Try
                Dim Cm As DbCommand = factory.CreateCommand
                Cm.CommandType = CommandType.StoredProcedure
                Cm.CommandText = ("sprocGetTipoMerce")
                Cm.Connection = conn
                conn.Open()
               
                Dim dr As DbDataReader = Cm.ExecuteReader()
                Try
                    If dr.Read Then
                        myCategory = FillDataRecord(dr)
                    End If
                    dr.Close()
                Finally
                    CType(dr, IDisposable).Dispose()
                End Try
                conn.Close()
            Finally
                CType(conn, IDisposable).Dispose()
            End Try
            Return myCategory
        End Function
        Private Shared Function FillDataRecord(ByVal myDataRecord As IDataRecord) As MerciContent
            Dim myCategory As MerciContent = New MerciContent
            myCategory.Id = myDataRecord.GetInt32(myDataRecord.GetOrdinal("idx"))
            myCategory.Descrizione = myDataRecord.GetString(myDataRecord.GetOrdinal("PIPPO")).ToString
            myCategory.Descrizione_Estesa = myDataRecord.GetString(myDataRecord.GetOrdinal("XXX"))


            Return myCategory
        End Function
    End Class

codbheind
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim selectionId As String = Request.Params("selectionId")
        If Not IsPostBack Then
            If Not selectionId Is Nothing Then
                catList.SelectedIndex = CInt(selectionId)
            End If

            catList.DataSource = MerciologicaDB.GetListMerci.Descrizione.ToString()

            catList.DataBind()
        End If
    End Sub

Web htm
<asp:DataList ID="catList" runat="server" ShowHeader="false" EnableViewState="false" CellSpacing="0">
                <SelectedItemStyle BackColor="GrayText" />
                  <SelectedItemTemplate>
                    <asp:HyperLink id="HyCat1" runat="server" CssClass="smallgraytext" Text='<%#Eval("PIPPO") %>' NavigateUrl='<%#"x"%>'>
            </asp:HyperLink>
                  </SelectedItemTemplate>
                <FooterStyle Wrap="false" />
                   <ItemTemplate>
          <asp:HyperLink ID="HyCat2" runat="server" CssClass="smallgraytext" Text='<%#Eval("PIPPO") %>' NavigateUrl='<%#"x"%>'>
          </asp:HyperLink>
        </ItemTemplate>
                 </asp:DataList>

grazie ciao<asp:HyperLink ID="HyCat2" runat="server" CssClass="smallgraytext" Text='<%#Eval("PIPPO") %>' l'errore quì.
Modificato da lorbax il 10 dicembre 2011 23.02 -

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.