Problem with databound composite control

Discussion in 'ASP .Net Building Controls' started by Yolanda Ceron, Nov 7, 2005.

  1. I'm developing an ASP.NET 1.1 composite control with a datalist. The
    datalist contains a template with some textboxes and some labels. The
    datalist template part i got working fine.
    My problem is with the Postback. I've tried different things that i
    have seen on different articles and tutorials without any results.
    The closer i've gotten to what I need is the implementation in the code
    provided below.
    The postback is working ok (I'm getting the information i update in the
    webpage, instead of what came initially from the database). But the
    problem is that the only way i've gotten it to "work" is by going
    database AGAIN after postback in order to get populate the datalist.

    Can anyone give me some help with this? I've been working with this
    problem for over 2 weeks now, without any good results :(
    What am I doing wrong? What am I missing?

    Thanks in advanced.

    Yolanda

    ----------------------
    Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Web.UI.WebControls

    <DefaultProperty("Text"), ToolboxData("<{0}:InformationGrid
    runat=server></{0}:InformationGrid>")> Public Class InformationGrid
    Inherits System.Web.UI.WebControls.WebControl
    Implements INamingContainer

    Dim _text As String
    Dim _connectionString As String
    Dim _repeatColumns As Integer
    Dim dlInformation As DataList

    <Bindable(True), Category("Appearance"), DefaultValue("")>
    Property [Text]() As String
    Get
    EnsureChildcontrols()
    Return _text
    End Get

    Set(ByVal Value As String)
    _text = Value
    End Set
    End Property
    <Bindable(True), Category("Appearance"), DefaultValue(3)>
    Property [RepeatColumns]() As Integer
    Get
    EnsureChildcontrols()
    Return _repeatColumns
    End Get

    Set(ByVal Value As Integer)
    _repeatColumns = Value
    End Set
    End Property

    Protected Overrides Sub CreateChildControls()
    CreateControlHierarchy()

    End Sub

    Private Sub CreateControlHierarchy()
    Dim itemTemplate As New gridItemTemplate(_imagePath)

    Controls.Clear()
    dlInformation = New DataList
    dlInformation.ID = "dlInfo"
    dlInformation.RepeatColumns = _repeatColumns
    itemTemplate.InstantiateIn(dlInformation)
    dlInformation.ItemTemplate = itemTemplate

    Me.Controls.Add(dlInformation)
    Me.DataBind()

    End Sub

    Private Function getDataSource() As DataTable
    'Goes to the database and fetches a datatable with the
    information i need
    '..........
    End Function


    Public Overrides Sub DataBind()

    Me.dlInformation.DataSource = getDataSource()
    MyBase.DataBind()

    End Sub
    End Class

    ----------------------
    Yolanda Ceron, Nov 7, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sleigh
    Replies:
    1
    Views:
    2,674
    sleigh
    Feb 12, 2004
  2. rodchar
    Replies:
    0
    Views:
    380
    rodchar
    Nov 26, 2007
  3. debartsa
    Replies:
    1
    Views:
    334
    John Saunders
    Apr 9, 2004
  4. Chad
    Replies:
    0
    Views:
    211
  5. Manu
    Replies:
    0
    Views:
    159
Loading...

Share This Page