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 7706375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:06:38+00:00 2026-06-01T00:06:38+00:00

Hy all, I’m developing a web application and I’m trying to use a checkboxlist.

  • 0

Hy all,

I’m developing a web application and I’m trying to use a checkboxlist. I want that for each selected item in that checkboxlist to create a new row in a table.So if I have 5 items and i check 3, I want a table to appear with 3 rows and in each row the selected items.This is how i get what items are checked:

 protected void Button1_Click(object sender, EventArgs e)
    {
        string str = string.Empty;

        foreach (ListItem item in check.Items)
        {
            str += item.Value;
        }
    }

My question is: how can I create a table with the selected values?? I’m using c# in an asp.net application

  • 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-06-01T00:06:39+00:00Added an answer on June 1, 2026 at 12:06 am

    You’ll need to recreate this table on every postback since it’s created dynamically.

    http://weblogs.asp.net/infinitiesloop/archive/2006/08/30/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx

    Here’s working sample code:

    <asp:CheckBoxList ID="check" runat="server">
        <asp:ListItem Text="Item 1" Value="1"></asp:ListItem>
        <asp:ListItem Text="Item 2" Value="2"></asp:ListItem>
        <asp:ListItem Text="Item 3" Value="3"></asp:ListItem>
    </asp:CheckBoxList>
    <asp:Button ID="Button1" runat="server" Text="Apply Selection" OnClick="Button1_Click" />
    <asp:Table ID="TblCheck" runat="server"></asp:Table>
    

    Codebehind:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) RecreateTable();
    }
    
    private void RecreateTable()
    {
        var selected = this.check.Items.Cast<ListItem>().Where(i => i.Selected);
        foreach (var item in selected)
        {
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            Label lbl = new Label();
            lbl.Text = item.Text;
            cell.Controls.Add(lbl);
            row.Cells.Add(cell);
            this.TblCheck.Rows.Add(row);
        }
    }
    
    protected void Button1_Click(object sender, EventArgs e)
    {
        //RecreateTable();
    }
    

    The button-click handler need not even to create it when it’s created from page_load anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have my application setup so that i can use a specific username
All I am trying to create an app that start capturing the video from
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
All, I am trying to create a table to receive user inputs (UGC). This
All I need is to create a file that contains a file names' list
I want use html5's new tag to play a wav file (currently only supported
All the examples seem to want the Ninject.Web.Common file reference. I can NuGet Ninect
All, I'm trying to use the jQuery Form Validator (http://docs.jquery.com/Plugins/Validation). However I'd like to
all i want to create the header file for database like this. it contains
All the recent VisualSVN Server posts made me want to check it out. I

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.