Problem with databound composite control

Problem with databound composite control

Post by Yolanda C » Wed, 09 Nov 2005 01:25:11

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.


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
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
Return _repeatColumns
End Get

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

Protected Overrides Sub CreateChildControls()

End Sub

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

dlInformation = New DataList
dlInformation.ID = "dlInfo"
dlInformation.RepeatColumns = _repeatColumns
dlInformation.ItemTemplate = itemTemplate


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()

End Sub
End Class