Dynamisk checkboxlist problem
Jeg har et problem med min dynamiske checklistbox.Checklistboxen genereres ud fra et DB-opslag og der fungerer sådan set også fint nok. Men når siden reloades (postbackes) forsvinder en af mine listoptions...
Lidt kode:
Sub CheckSMSData(ByVal strSearch As String)
Dim tTable As DataTable
Dim rRow As DataRow
Dim cColumn As DataColumn
Dim strSearch1 As String
For Each tTable In objDBDataSet.Tables
For Each rRow In tTable.Rows
For Each cColumn In tTable.Columns
strSearch1 = (rRow(cColumn.ColumnName))
If strSearch1 <> strSearch Then
ValCheckDataCompare = 1
End If
Next cColumn
Next rRow
Next tTable
If ValCheckDataCompare = 0 Then
show(strSearch)
End If
ValCheckDataCompare = 0
strSearch = ""
objDBDataSet.Clear()
End Sub
Sub show(ByVal strSearch As String)
oCheckBoxList.RepeatDirection = RepeatDirection.Vertical
If Not (IsPostBack) Then
oCheckBoxList.Items.Add(New ListItem(strSearch))
End If
CheckBoxPlaceholder.Controls.Add(oCheckBoxList)
End Sub
HTML:
<form id="Form1" method="post" runat="server">
<asp:placeholder id="CheckBoxPlaceholder" runat="server"></asp:placeholder>
</form>