DataList + CheckBox

Discussion in 'ASP .Net' started by Paperback Writer, Jul 4, 2005.

  1. I have a DataList with a lot of items where the user can select them trough
    the CheckBoxes but i don't have idea how to capture these values from the
    checkboxes to insert in my DataBase....How to accomplish that ?

    --
    Please, check my theSpoke:
    http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx
     
    Paperback Writer, Jul 4, 2005
    #1
    1. Advertising

  2. You have to iterate through each item in the datalist find the checkbox
    control and check if it is selected. assuming your datalist's id is dl and
    the checkbox id is controlsid

    Dim alSelectedValues As New ArrayList

    For Each item As DataListItem In dl.Items
    'check the item isn't a header or footer
    If item.itemindex > -1 Then
    Dim cb As CheckBox = item.FindControl("controlsid")

    Dim value As String = cb.Text
    Dim checked As Boolean = cb.Checked

    If checked Then
    alSelectedValues.Add(value)
    End If
    End If

    Next

    good luck jd

    "Paperback Writer" wrote:

    > I have a DataList with a lot of items where the user can select them trough
    > the CheckBoxes but i don't have idea how to capture these values from the
    > checkboxes to insert in my DataBase....How to accomplish that ?
    >
    > --
    > Please, check my theSpoke:
    > http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx
    >
    >
    >
     
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 4, 2005
    #2
    1. Advertising

  3. This code is OK only for Datagrid not only for Datalist. I search the way to
    access the footer data from outside of dataset event. If u have, pls inform
    me.
    Kaung Htut Oo



    "london calling" wrote:

    > You have to iterate through each item in the datalist find the checkbox
    > control and check if it is selected. assuming your datalist's id is dl and
    > the checkbox id is controlsid
    >
    > Dim alSelectedValues As New ArrayList
    >
    > For Each item As DataListItem In dl.Items
    > 'check the item isn't a header or footer
    > If item.itemindex > -1 Then
    > Dim cb As CheckBox = item.FindControl("controlsid")
    >
    > Dim value As String = cb.Text
    > Dim checked As Boolean = cb.Checked
    >
    > If checked Then
    > alSelectedValues.Add(value)
    > End If
    > End If
    >
    > Next
    >
    > good luck jd
    >
    > "Paperback Writer" wrote:
    >
    > > I have a DataList with a lot of items where the user can select them trough
    > > the CheckBoxes but i don't have idea how to capture these values from the
    > > checkboxes to insert in my DataBase....How to accomplish that ?
    > >
    > > --
    > > Please, check my theSpoke:
    > > http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx
    > >
    > >
    > >
     
    =?Utf-8?B?S2F1bmcgSHR1dCBPbw==?=, Jul 18, 2005
    #3
    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. Nevyn Twyll
    Replies:
    8
    Views:
    1,964
  2. tshad
    Replies:
    0
    Views:
    579
    tshad
    Apr 15, 2005
  3. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,430
    ThunderMusic
    Jan 25, 2006
  4. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    864
    David Wier
    Oct 6, 2006
  5. Replies:
    1
    Views:
    472
Loading...

Share This Page