Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6680171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:26:38+00:00 2026-05-26T04:26:38+00:00

I need to insert multiple checkbox text into a column in a mssql database,

  • 0

I need to insert multiple checkbox text into a column in a mssql database,
I could use a single checkbox list and make this thing easier, however,
the requirements are to display separate html rows and columns with several checkboxes ,
kinda like Check all the conditions that apply design , but for several criterias, so I am guessing probably a string builder or array will do so I am attempting the following code but there is gotta be a better cleaner way than manually doing this for each checkbox?

Please help with my code below:

asp.net page
<td>
            &nbsp;
            <span style="color: #FF0000">*</span> Specify Criteria Used (check all that apply)<br />
&nbsp;<span style="text-decoration: underline">Signs &amp; Symptoms<br />
            </span>
            <br />
            <asp:CheckBox ID="eventCriteria1" runat="server" 
                Text="Purulent drainage or material" />
            <br />
            <asp:CheckBox ID="eventCriteria2" runat="server"  Text="Pain or tenderness"/>
            <br />
            <asp:CheckBox ID="eventCriteria3" runat="server" Text="Localized swelling" />
            <br />
            <asp:CheckBox ID="eventCriteria4" runat="server" Text="Redness" />
            <br />
            <asp:CheckBox ID="eventCriteria5" runat="server" Text="Heat" />
            <br />
            <asp:CheckBox ID="eventCriteria6" runat="server" Text="Fever"/>
            <br />
            <asp:CheckBox ID="eventCriteria7" runat="server" 
                Text="Incision deliberately opened by surgeon"/>
            <br />
            <asp:CheckBox ID="eventCriteria8" runat="server" 
                Text="Wound spontaneously dehisces"/>
            <br />
            <asp:CheckBox ID="eventCriteria9" runat="server"  Text="Abscess"/>
            <br />
            <asp:CheckBox ID="eventCriteria10" runat="server" Text="Hypothermia" />
            <br />
            <asp:CheckBox ID="eventCriteria11" runat="server" Text="Apnea" />
            <br />
            <asp:CheckBox ID="eventCriteria12" runat="server" Text="Bradycardia" />
            <br />
            <asp:CheckBox ID="eventCriteria13" runat="server" Text="Lethargy"/>
            <br />
            <asp:CheckBox ID="eventCriteria14" runat="server" Text="Cough"/>
            <br />
            <asp:CheckBox ID="eventCriteria15" runat="server" Text="Nausea"/>
            <br />
            <asp:CheckBox ID="eventCriteria16" runat="server" Text="Vomiting"/>
            <br />
            <asp:CheckBox ID="eventCriteria17" runat="server" Text="Dysuria"/>
            <br />
            <asp:CheckBox ID="eventCriteria18" runat="server" Text="Other evidence of infection found on direct
     exam, during surgery, or by diagnostic tests"/>
            <br />
            <asp:CheckBox ID="eventCriteria19" runat="server"  
                Text="Other signs & symptoms"/>

        </td>
        <td colspan="2" style="height: 23px; text-decoration: underline; width: 307px;" 
            valign="top">
            <br />
            Laboratory<br />
            <br />
            <asp:CheckBox ID="eventCriteria20" runat="server" 
                Text="Positive culture" />
            <br />
            <asp:CheckBox ID="eventCriteria21" runat="server" Text="Not cultured"/>
            <br />
            <asp:CheckBox ID="eventCriteria22" runat="server" 
                Text="Positive blood culture" />
            <br />
            <asp:CheckBox ID="eventCriteria23" runat="server" 
                Text="Blood culture not done or no organisms detected in blood" />
            <br />
            <asp:CheckBox ID="eventCriteria24" runat="server" 
                Text="Positive Gram stain when culture is negative or not done" />
            <br />
            <asp:CheckBox ID="eventCriteria25" runat="server" 
                Text="Other positive laboratory tests"/>
            <br />
            <asp:CheckBox ID="eventCriteria26" runat="server" 
                Text="Radiographic evidence of infection"/>
            <br />

            <br />
            Clinical Diagnosis<br />
            <asp:CheckBox ID="eventCriteria27" runat="server" 
                Text="Physician diagnosis of this event type"/>
            <br />
            <asp:CheckBox ID="eventCriteria28" runat="server" 
                Text="Physician institutes appropriate antimicrobial
    therapy"/>

        </td>



Code:


StringBuilder sb = new StringBuilder(); 
        if (eventCriteria1.Checked)
        {
            sb.Append(eventCriteria1.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }

        if (eventCriteria2.Checked)
        {
            sb.Append(eventCriteria2.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }

        if (eventCriteria3.Checked)
        {
            sb.Append(eventCriteria3.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }

        if (eventCriteria4.Checked)
        {
            sb.Append(eventCriteria4.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }

        if (eventCriteria5.Checked)
        {
            sb.Append(eventCriteria5.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }
        if (eventCriteria6.Checked)
        {
            sb.Append(eventCriteria6.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 
        }
        if (eventCriteria7.Checked)
        {
            sb.Append(eventCriteria7.Text + ",");
            //Here stringValue is System.Text.StringBuilder variable 

        }

        cmd.Parameters.AddWithValue("@eventCriteria", sb.ToString());
.
.
.
.
.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:26:38+00:00Added an answer on May 26, 2026 at 4:26 am

    You need to put the CheckBoxes in some sort of a container like a Panel or PlaceHolder, and then you can do this:

    ASPX:

    <asp:Panel ID="Panel1" runat="server">
        <asp:CheckBox ID="chk1" runat="server" Text="..." />
        ...
    </asp:Panel>
    

    Code-behind for ASP.NET 3.5 and above:

    foreach (CheckBox chk in Panel1.Controls.OfType<CheckBox>())
    {
        if (chk.Checked)
        {
            //update parameter
            cmd.Parameters["@eventCriteria"].Value += String.Format("{0},", chk.Text);
        }
    }
    
    //you'll probably need to trim the trailing comma too
    cmd.Parameters["@eventCriteria"].Value = cmd.Parameters["@eventCriteria"].Value.TrimEnd(',');
    

    Code-behind for ASP.NET 2.0 and earlier:

    foreach (Control ctrl in Panel1.Controls)
    {
        if (ctrl is CheckBox)
        {
            CheckBox chk = (CheckBox)ctrl;
            if (chk.Checked)
            {
                //update parameter
                cmd.Parameters["@eventCriteria"].Value += String.Format("{0},", chk.Text);
            }
        }
    }
    
    //you'll probably need to trim the trailing comma too
    cmd.Parameters["@eventCriteria"].Value = cmd.Parameters["@eventCriteria"].Value.TrimEnd(',');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert multiple rows into SQL Server database (100 at a time)
I need to insert multiple records into mysql database at once. What I am
Need help with PHP Mysql code to insert multiple select data into database. With
I need some help to insert comma separates strings into multiple columns into db.
Need to insert selected text on the page into textarea. There must be some
I need to insert multiple rows in my Mysql database.my rows are available in
i need to perform a insert query for multiple rows whereby the first column
I need to insert many sql rows into oracle database very fast. IndexData is
Is there a quick way to insert multiple values into one column while the
I need to insert multiple records into a table. The number of records depend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.