1

am building a task management system using vb.net. How to set a textbox field beside each checkboxlist so when the user tick the checkbox he can comment too for this item and submit the whole finished tasks ? below is my code

 Sub GetGroups()
        cblGroups.DataSource = Task.Components.Tasks.GetAllTasks
        cblGroups.DataTextField = "TaskName"
        cblGroups.DataValueField = "ID"
        cblGroups.DataBind()


    End Sub


  For Each item As ListItem In cblGroups.Items
            If item.Selected Then

'reading each item value

End if

Next

Dan
  • 343
  • 3
  • 9
  • 21

2 Answers2

0

I think you should be using a DataGridView instead. In there you can have a checkbox column and a textbox column, also a new row placeholder to put new tasks. If you don't like DataGridView, you can use alternatives.

Your other option would be to maintain a list of CheckBox controls and their TextBox pairs, essentially doing data grid's job. You are okay at first, but then you may need scrolling etc., so why not use a built-in control, where such issues are already solved out of the box.

Community
  • 1
  • 1
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
  • I prefer to use it withour dridview, can we manage to put textbox beside each checkbox item and read the value of the text ? – Dan May 30 '14 at 18:57
  • @Dan: You can do everything - time is the only concern. Coding this home-made data grid is out of scope, please ask a concrete question about implementation, if you have one. – Victor Zakharov May 30 '14 at 19:01
  • whats the built-in control you have suggested ? – Dan May 30 '14 at 19:04
  • @Dan: [DataGridView](http://msdn.microsoft.com/en-us/library/vstudio/system.windows.forms.datagridview). – Victor Zakharov May 30 '14 at 19:06
0
    'Check through each of the items
    For Each item As ListItem In cblGroups.Items
        'If this particular item is checked
        If item.Selected = True Then
            'Dynamically create a HTML Textbox
            item.Text = [String].Format("{0}<input id=""TextBox{0}"" name=""TextBox{0}"" / >", item.Text)
        Else
            'Otherwise simply store the normal value
            item.Text = [String].Format("{0}", item.Text)
        End If
    Next
Rita Chavda
  • 191
  • 2
  • 16