473,466 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Want to store multiple checkboxlists selected value in SQL2005

20 New Member
Hello friends,

I m using ASP.NET with C# 2005 and SQL SERVER 2005 for the ASP.Net Website.

I m using sqldatasource to connect and retrieve the data from database and then it displays the data in the gridview on the button click event.I have created the stored procedure for insert and select query.

Now in my application i have used checkboxlist where there can be multiple selection for the hobbies.
I want to know how can i store the multiple value into the same column and also want to display it in the gridview all values name.

I can display only the first value from the checkboxlist if at all i select the multiple values...I also want that i can edit or delete the values thru gridview.

Here is the code that i have used just for the reference ::

Expand|Select|Wrap|Line Numbers
  1.  
  2.  protected void cmdsubmit_Click(object sender, EventArgs e)
  3.     {
  4.  foreach (ListItem item in CheckBoxList1.Items)
  5.         {
  6.             if (item.Selected.Equals("READ"))
  7.             {
  8.                 SqlDataSource1.InsertParameters["hobbies"].Name = CheckBoxList1.SelectedItem.Value.ToString();
  9.             }
  10.             if (item.Selected.Equals("WRITE"))
  11.             {
  12.                 SqlDataSource1.InsertParameters["hobbies"].DefaultValue = CheckBoxList1.SelectedItem.Value.ToString();
  13.             }
  14.         }      
  15.         SqlDataSource1.Insert();
  16.         GridView1.Visible = true;
  17.  }
  18.  

Hope this helps anyone to answer.

Pls help me out and rectify my errors.This is just the simple if statements written for only 2contents in checkboxlists.If there are 10contents then what can be done ??
Apr 9 '07 #1
1 3066
Motoma
3,237 Recognized Expert Specialist
The typical way of doing this is through a technique called database normalization. Please take a look at the discussion had in this thread, in particular, read through the links that I posted towards the end of the discussion.
Apr 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
2
by: murraymiken | last post by:
I'm looking to have multiple multiple-select-boxes on a page. But I can only get the contents from the last selected value within a box, via PHP. I've tried numerous methods. What am I doing...
3
by: imrantbd | last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php...
3
by: Andreas Wöckl | last post by:
HI Group! I have to programmatically create a user input form with various Checkbox and RadioButton lists - Beside every List I have to place an image button that is able to reset the...
1
by: assgar | last post by:
Hi I was using a schroll bar to display multiple rows of dynamically created from database records. The scrolling was not displaying the data properly so I have decided to use pagination. The...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
17
by: shivasusan | last post by:
Hi! In my program, I have multiple check boxs.(more the 10) But i give rights to select 2 check boxs, If i select more then 2 check boxs, I want to display alert message. Please any one post...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.