CheckBoxList

Discussion in 'ASP .Net Web Controls' started by Rabso, Jul 9, 2004.

  1. Rabso

    Rabso Guest

    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").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>"
     
    Rabso, Jul 9, 2004
    #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. Francois Verbeeck
    Replies:
    0
    Views:
    1,905
    Francois Verbeeck
    Jun 24, 2003
  2. Khan Imran

    Re: checkboxlist control

    Khan Imran, Jun 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    479
    Khan Imran
    Jun 30, 2003
  3. Ignacio Martinez

    Re: checkboxlist control

    Ignacio Martinez, Jun 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    470
    Ignacio Martinez
    Jun 30, 2003
  4. JD
    Replies:
    5
    Views:
    11,846
    NetArchitect
    Aug 8, 2007
  5. Patrick.O.Ige
    Replies:
    5
    Views:
    19,297
    Patrick.O.Ige
    Jun 19, 2005
Loading...

Share This Page