how to make a dymanic checkboxes in c#

Posted on 2011-03-20
Last Modified: 2012-06-22
how to make a dymanic checkboxes in c# such as if i want a for loop of 10 checkboxes on the page.
Question by:cbrune
  • 3

Expert Comment

ID: 35178219
use check box list to add 10 checkboxes dynamically,
then use this code to find the checkbox which is selected..
foreach(ListItem item in CheckBoxList1.Items)
            if (item.Selected)
                //Do any action
if you create checkboxes it is hard to find which is selected instead of checkboxlist....

Author Comment

ID: 35178227
can you give me more code then this? sorry im a beginner at

Expert Comment

ID: 35178239
could you please tell me from where you want to load the values for those checkboxes

Accepted Solution

ramkihardy earned 500 total points
ID: 35178262
This is how i am populating a checkboxlist from a table
i ll first establish a connection and get the values from the tables form the database..and populate the checkboxlist..
CheckBoxList CHK = new CheckBoxList();
                CHK.ID = "CHK" + currentQuestion.SurveyQuestionId;
                CHK.DataSource = currentQuestion.LookupValues;
                CHK.DataTextField = "LookUpValue";
                CHK.DataValueField = "SurveyLookUpId";
                CHK.RepeatDirection = RepeatDirection.Horizontal;                
                CHK.BorderWidth = 0;
                //CHK.RepeatColumns = currentQuestion.LookupValues.Count;
                //CHK.RepeatLayout = RepeatLayout.Flow;
                CHK.RepeatColumns = 1;
                CHK.CssClass = "dCheckBox";

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use xmlReader and idatareader  ? 4 55
what technologies offer Authentication over Web Services? 4 103
DateTimepicker 4 33
Replace &lt; with < 14 54
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now