Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 April 3rd, 2008, 01:55 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default Storing checkboxes value in a single row

HI ALL

I AM MAKING A WEB APP USING C#,SQL SERVER 2005. I M USING VISUAL STUDIO 2005 PRO.

I HAVE MULTIPLE CHECKBOXES. PROBLEM IS THAT I HAVE TO STORE THE CHECKED VALUES IN A SINGLE COLUMN AS A COMMA SEPARATED VALUES. EXAMPLE UNDER HOBBIES CATEGORY, I HAVE CHECKBOXES FOR READING, EATING, SINGING ETC., IN MY TABLE I HAVE ONE COLUMN 'HOBBIES',DEPENDING ON THE USER SELECTION, THE VALUES SHOULD BE STORED IN THE TABLE UNDER COLUMN HOBBIES AS READING, EATING(AS A COMMA SEPARATED VALUE, IN A SINGLE ROW)

I AM NOT USING ANY REPEATER CONTROL, OR GRIS=D VIEW, I AM PASSING IT IN A SIMPLE WAY...
TELL ME HOW TO DO IT SHOWING CODES.....

 
Old April 3rd, 2008, 02:30 PM
Authorized User
 
Join Date: Sep 2007
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

CAPS! My eyes! Thery're burning!

But I'm in a nice mood and my crystall ball shows something like this:

Code:
StringBuilder sb = new StringBuilder();
foreach (Control ctrl in Controls)
{
    if (ctrl is CheckBox)
    {
        sb.AppendFormat("{0}={1},", ctrl.Name, ((CheckBox)ctrl).Checked));
    }
}

if (sb.Length > 0)
{
    sb.Length--;
}

string yourString = sb.ToString();
 
Old April 8th, 2008, 12:13 AM
Authorized User
 
Join Date: May 2007
Posts: 95
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thanks for the help, but one more thing is intriguing me..., that is how to retrieve back the chaeckbox values in page which i have inserted.
Suppose i have textbox where i will enter studentid and will press 'Go' button, then all the records will get fetched, including the checkbox. How to get the checkbox value back into the page, can u explain me through code...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Consolidating multiple occurences in a single row ssray23 SQL Language 11 May 18th, 2007 11:00 AM
Converting large columns into a single row rahulpokharna SQL Server 2000 3 January 10th, 2006 02:14 AM
How to send multiple columns’ data of a single row swadhinm ASP.NET 1.x and 2.0 Application Design 2 June 1st, 2005 07:59 AM
Storing complete table rows in a single field KenNeedham Oracle 2 January 22nd, 2004 01:45 PM
Storing single and double quotes in text roniestein Access 4 December 30th, 2003 05:09 PM





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