Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > Visual Web Developer 2005
|
Visual Web Developer 2005 Discuss creating ASP.NET 2.0 sites with Microsoft's Visual Web Developer 2005. If your question is more specific to a piece of code than the Visual tool, see the ASP.NEt 2.0 forums instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Web Developer 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2007, 10:55 AM
w_w w_w is offline
Registered User
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to store values from checked checkboxlists~c#

Visual Studio 2005 [C#], MS SQL 2005 database

I am working on a survey using VS 2005, connected to a MS SQL 2005 database. Using ASP.NET2.0 controls (textbox, checkboxlist, dropdownlist). A submit button would run "SqlDataSource1.Insert();" to insert user data into the connected database.

Using the control ID as the formfield name, I have managed to pass values entered in textboxes, or selected via dropdownlist into the database.

<InsertParameters>
<asp:formparameter Name="businessName" formfield="BusinessName_TextBox"
Type="String" />

<asp:formparameter Name="mainContact"
formfield="MainContact_TextBox" Type="String" />
<asp:formparameter Name="email"
formfield="EmailAddress_TextBox" Type="String" />
<asp:formparameter Name="Q1"
formfield="Part1Q1_DropDownList" Type="String" />

~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~

But I do not know how to store values from the checkboxlist. Within the database I have created fields for all available options. (E.g Q2a, Q2b, Q3c) and the aim is to pass the checked values into its corresponding fields in the database. So that If question 2 was a checkboxlist. When someone checked 1st box, its corresponding value are stored in 'Q2a'.

I am using C#, could anyone assist? Many thanks in advance,


kind Regards,

William
 
Old August 14th, 2007, 11:30 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

One Option might be:

If each question on the form has a corrosponding field in the database, you could simply change the column type from varchar to bit and pass in the value Q2a.Checked will pass either true or false into the database. (You don't have to change the field type to bit, that is simply what I would do)

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to store "SET" values to Vector ? msg2ajay JSP Basics 1 September 4th, 2007 06:45 AM
How to retrieve checkbox values which are checked SMM Classic ASP Professional 2 June 3rd, 2007 06:45 PM
How 2 store checkboxes values in MySQL babaloui Beginning PHP 0 March 13th, 2006 04:05 AM
To split values and store in the database lily611 SQL Server 2000 3 July 15th, 2004 09:01 AM
store multiple values in a string bamboat_3 General .NET 3 May 23rd, 2004 07:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.