asp.net problem
-
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
-
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
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.
-
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
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
}
} -
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
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.
-
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.
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
-
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.
-
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