CheckBoxList

R

Rabso

I have a problem with CheckBoxList here is my code
'---------------------------------------------------------------------------------
Dim ds As DataSet
Dim ds2 As DataSet
Dim ws As New thing()
Dim ws As New thing()
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
ds = ws.thing1()
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim id = ds.Tables(0).Rows(i)("sid").ToString()
Dim t As String
t = t + "<table border='1' cellpadding='0' cellspacing='0'><tr>"
t = t + "<td colspan=2>" + ds.Tables(0).Rows(i)("sid").ToString() + "-" + ds.Tables(0).Rows(i)(1).ToString + "</td></tr>"
ds2 = ws2.thing2(id)
Dim x = 0
For x = 0 To ds2.Tables(0).Rows.Count - 1
With CheckBoxList1
.Items.Add(ds2.Tables(0).Rows(x)("aihaga").ToString())
CheckBoxList1.DataTextField = ds2.Tables(0).Rows(x)("aihaga").ToString()
t = t + "<tr><td>" + "<input id='CheckBoxList1' type='checkbox'>" + CheckBoxList1.DataTextField + "</asp:CheckBoxList> </td></tr>"
t = t + "<tr><td>" + CheckBoxList1.DataTextField + "</td></tr>"
End With
Next
t = t + "</table>"
Me.Label1.Text = t
Next

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String
Dim li As ListItem
msg = ""
For Each li In CheckBoxList1.Items
If li.Selected = True Then
msg = msg & "<BR>" & li.Text & " selected." & " with a value of : " & li.Value & "."
End If
Next
Message.Text = msg
End Sub
End Class
'----------------------------------------------------------------------------------
The code goes fine that It shows the results from the table in the database but it shows only the results without the checkbox

t = t + "<tr><td>" + CheckBoxList1.DataTextField + "</td></tr>"

and when I put the code with

t = t + "<tr><td>" + "<input id='CheckBoxList1' type='checkbox'>" + CheckBoxList1.DataTextField + "</asp:CheckBoxList> </td></tr>"

it shows every thing right but the button code doesn't work

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String
Dim li As ListItem
msg = ""
For Each li In CheckBoxList1.Items
If li.Selected = True Then
msg = msg & "<BR>" & li.Text & " selected." & " with a value of : " & li.Value & "."
End If
Next
Message.Text = msg
End Sub
End Class

and if I drag and drop any checkboxlist the code works of the button
'------------------------------------------------------------------------------------
What I need is how to show the checkboxes and the results of the dbase tables

t = t + "<tr><td>" +xxxxx+ "</tr></td>"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top