Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to Store CheckBoxList selected values as asingle record

dotnetprogramedotnetprograme Posts: 3Member
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 Posts: 258Member
    : 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.