Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CheckBoxList

Reply
Thread Tools

CheckBoxList

 
 
Rabso
Guest
Posts: n/a
 
      07-09-2004
If there is any one can help me how to show a checkbox
like this
t = t + "<tr><td>" +code to show the checkboxes+ "</tr></td>"
the whole code is here
Dim ds As DataSet
Dim ds2 As DataSet
Dim ws As New thing()
Dim ws2 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").ToStrin g())
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>"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkboxlist inside Repeater - doesn't fire click event for Checkboxlist JD ASP .Net 5 08-08-2007 11:28 AM
How to get Selected item in a Databinded CheckBoxList when CheckBoxlist is in a DataList? Patrick.O.Ige ASP .Net 5 06-19-2005 06:11 AM
Re: checkboxlist control Ignacio Martinez ASP .Net 1 06-30-2003 02:51 PM
Re: checkboxlist control Khan Imran ASP .Net 0 06-30-2003 01:36 PM
/!\ How to colorize selected checkbox in checkboxlist control ? Francois Verbeeck ASP .Net 0 06-24-2003 03:13 PM



Advertisments