Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to Store CheckBoxList selected values as asingle record

dotnetprogramedotnetprograme Member Posts: 3
Hi

I have to store selected item of checkbox list along with
some other text values and dropdown values (say information in a given page)
which user fills or selects.Theseall vaules will be regarding one
object.(For example NAme,Type,Price,features etc.......).In one of the filling vaules i have
CheckboxLIst .So,i wann to know how to add a checkboxList Vaules as asingle record in Database.Thank you in adavance.
Please anyone help me.

THanks,
Dotnetprograme




Comments

  • GogiGogi Member Posts: 258
    : Hi
    :
    : I have to store selected item of checkbox list along with
    : some other text values and dropdown values (say information in a given page)
    : which user fills or selects.Theseall vaules will be regarding one
    : object.(For example NAme,Type,Price,features etc.......).In one of the filling vaules i have
    : CheckboxLIst .So,i wann to know how to add a checkboxList Vaules as asingle record in Database.Thank you in adavance.
    : Please anyone help me.
    :
    : THanks,
    : Dotnetprograme
    :
    :
    :
    :
    :

    Hi,

    I think you can use one string to store CheckBoxList states.
    The code could be something like this:
    [code]
    Dim res_string As String
    Dim n As Integer

    For n=0 CheckBoxList1.Items.Count -1
    If CheckBoxList1.Items(n).Selected=True Then
    res_string+="1"
    Else
    res_string+="0"
    End If
    Next n
    [/code]

    Now you will have all the checkboxlist states in a single string (record).Just store it in your DB.

    For loading the checkboxlist states from database to your application you could use this code:
    [code]
    'Let's say you loaded the variable res_string from your database,with the value you stored above.Now,just go through the string and get the states:

    Dim n As Integer

    For n=0 To CheckBoxList1.Items.Count - 1
    CheckBoxList1.Items(n).Selected=CBool(Mid(res_string,n+1,1)))
    Next n
    [/code]

    Hope this helps!
Sign In or Register to comment.