if a checkboxlist is not selected shows save as number 0 in DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suely
    New Member
    • Sep 2012
    • 3

    if a checkboxlist is not selected shows save as number 0 in DB

    I'm working in a web aplication in c#, vs 2008, framework 3.5, I need to assign a value to a var, in this case "problemas" ,
    when I tried to save the value that I have in the checkboxlist, it does, but if don't selected, can't show 0, besides if I change the value "problemas = 9" to problemas = 111111" doesn't works, I've tried a lot of options but nothing works to me, please help, thanks in advance.

    Code:
    protected void ckblProblemas_SelectedIndexChanged(object sender, EventArgs e)
    {
    int problemas = 0;
    {
    if (ckblProblemas.SelectedValue.Equals("9"))
                    {
                        problemas = 9;
                    }
                       
                    else
                    {
                        problemas.Equals("0");
                    }
    Last edited by zmbd; Sep 26 '12, 07:09 PM. Reason: When posting code, please format the code using the <CODE/> button.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    I'm not quite sure i understood, if the problem is to make problemas = "111111", change its type, since an integer cannot be larger than 32,000 (aprox). Use a long.

    If your problem is with the selected value. Select a default value in the 'load' sub.

    HTH

    Comment

    • suely
      New Member
      • Sep 2012
      • 3

      #3
      I can handle problemas=111, it was just an example because I realise that doesn´t save the value from problemas=111.. but in my database I save the value, my problem is if the user don´t select anything in the checkboxlist, I need to save that as a 0 in my db, but now I can´t, anyway, I'll try what you said, thanks for your reply. :)

      Comment

      Working...