?
Solved

how to make a dymanic checkboxes in c# asp.net

Posted on 2011-03-20
4
Medium Priority
?
270 Views
Last Modified: 2012-06-22
how to make a dymanic checkboxes in c# asp.net such as if i want a for loop of 10 checkboxes on the page.
0
Comment
Question by:cbrune
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

by:ramkihardy
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....
0
 

Author Comment

by:cbrune
ID: 35178227
can you give me more code then this? sorry im a beginner at asp.net
0
 
LVL 2

Expert Comment

by:ramkihardy
ID: 35178239
could you please tell me from where you want to load the values for those checkboxes
0
 
LVL 2

Accepted Solution

by:
ramkihardy earned 2000 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";
                CHK.DataBind();
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

770 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