Solved

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

Posted on 2011-03-20
4
256 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
  • 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 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";
                CHK.DataBind();
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

10 Experts available now in Live!

Get 1:1 Help Now