Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. asp.net problem

asp.net problem

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelp
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    babbuamit
    wrote on last edited by
    #1

    I have a aspx page. In this page i have 26 checkboxes. Now user can select no. of checkboxes as he want. Now plz tell me how i store those selected checkboxes into the database. for that either we have to make 26 fields for each checkbox or make one field for all checkbox. How i store the user selected checkboxes into the database. Send the code for this in C#. Thanks amit

    G M P 3 Replies Last reply
    0
    • B babbuamit

      I have a aspx page. In this page i have 26 checkboxes. Now user can select no. of checkboxes as he want. Now plz tell me how i store those selected checkboxes into the database. for that either we have to make 26 fields for each checkbox or make one field for all checkbox. How i store the user selected checkboxes into the database. Send the code for this in C#. Thanks amit

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      I can think of a couple options. Which one you choose depends on how you want to access the stored data. 1. 26 boolean database fields: Easy access but largest storage option. 2. 32-bit unsigned integer using its bits to store each result: Harder access but saves space.

      1 Reply Last reply
      0
      • B babbuamit

        I have a aspx page. In this page i have 26 checkboxes. Now user can select no. of checkboxes as he want. Now plz tell me how i store those selected checkboxes into the database. for that either we have to make 26 fields for each checkbox or make one field for all checkbox. How i store the user selected checkboxes into the database. Send the code for this in C#. Thanks amit

        M Offline
        M Offline
        Mike Ellison
        wrote on last edited by
        #3

        babbuamit wrote:

        for that either we have to make 26 fields for each checkbox or make one field for all checkbox.

        You're answering your own question here. First, decide how you want to store the information in your database. Once you determine that you could loop through the selected items in the checkboxlist using code like this:

        foreach (ListItem item in MyCheckBoxList)
        {
        if (item.Selected)
        {
        //... this is a checked item... store it however you've decided you want to
        }
        }

        1 Reply Last reply
        0
        • B babbuamit

          I have a aspx page. In this page i have 26 checkboxes. Now user can select no. of checkboxes as he want. Now plz tell me how i store those selected checkboxes into the database. for that either we have to make 26 fields for each checkbox or make one field for all checkbox. How i store the user selected checkboxes into the database. Send the code for this in C#. Thanks amit

          P Offline
          P Offline
          Prasad Babu A
          wrote on last edited by
          #4

          Hi, Better to store in one field at DB. U can use 1 for CheckBox Selection and 0 for CheckBox unselection. U can store that field value like 1,1,1,1,0,0,1...etc. This is very easy.. bye Pessi.

          R B 2 Replies Last reply
          0
          • P Prasad Babu A

            Hi, Better to store in one field at DB. U can use 1 for CheckBox Selection and 0 for CheckBox unselection. U can store that field value like 1,1,1,1,0,0,1...etc. This is very easy.. bye Pessi.

            R Offline
            R Offline
            RichardGrimmer
            wrote on last edited by
            #5

            how about a bit mask - define constants to be powers of 2, and use logical AND to see if the bit is set "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

            1 Reply Last reply
            0
            • P Prasad Babu A

              Hi, Better to store in one field at DB. U can use 1 for CheckBox Selection and 0 for CheckBox unselection. U can store that field value like 1,1,1,1,0,0,1...etc. This is very easy.. bye Pessi.

              B Offline
              B Offline
              babbuamit
              wrote on last edited by
              #6

              Sir, Thanks for this. If possible send the code for this. amit

              R 1 Reply Last reply
              0
              • B babbuamit

                Sir, Thanks for this. If possible send the code for this. amit

                R Offline
                R Offline
                RichardGrimmer
                wrote on last edited by
                #7

                Bit masks are fairly straightforward if you know a bit of binary... Basically, each power of 2 "resolves" to a new binary digit...so 2^1 = 2 = 10, 2^2 = 4 = 100, 2^3 = 8 = 1000 etc.... So if you define a bit field, you can take a base value of 0, and add a value to the bit field by performing a logical OR... Base value = 0... DEFINE FIRST_CONSTANT = 2 //10 DEFINE SECOND_CONSTANT = 4 //100 bitMask = bitMask || FIRST_CONSTANT //set first value bitMask = bitMask || SECOND_CONSTANT //set second value //Check values if (bitMask && FIRST_CONSTANT) //first value set if (bitMask && SECOND_CONSTANT) //second value set "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups