Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-20
4
Medium Priority
?
274 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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