473,394 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CheckBoxList Data Binding

Tom
Hi,

I have a webform which has DropDownList, RadioButtonList
and CheckBoxList. All values are in webform, but not
select from DB table as they do not need to be used as
search requirements.

For DropDownList and RadioButtonList, there is only one
item is selected and store in DB table.

I use

this.DropDownListItem.SelectedItem.Value = ds
["DropDownListItem"].ToString();
and
this.RadioButtonListItem.SelectedItem.Value = ds
["RadioButtonListItem"].ToString();

When the user edit the values of DropDownList and
RadioButtonList, the web form will display the selected
options.

However, how can I deal with a CheckBoxList? I can use a
foreach loop to get the selected values.

How can the selected values of CheckBoxList be displayed
in the web form when the user wants to edit it next time?
Do I need a delimitor to separate the checkboxlist values
before store them in DB?

Any better idea?

Thanks
Nov 18 '05 #1
1 5370
Tom wrote:
Hi,

I have a webform which has DropDownList, RadioButtonList
and CheckBoxList. All values are in webform, but not
select from DB table as they do not need to be used as
search requirements.

For DropDownList and RadioButtonList, there is only one
item is selected and store in DB table.

I use

this.DropDownListItem.SelectedItem.Value = ds
["DropDownListItem"].ToString();
and
this.RadioButtonListItem.SelectedItem.Value = ds
["RadioButtonListItem"].ToString();

When the user edit the values of DropDownList and
RadioButtonList, the web form will display the selected
options.

However, how can I deal with a CheckBoxList? I can use a
foreach loop to get the selected values.

How can the selected values of CheckBoxList be displayed
in the web form when the user wants to edit it next time?
Do I need a delimitor to separate the checkboxlist values
before store them in DB?

Any better idea?

Thanks


Tom,

You can iterate the items in the checkboxlist using a couple of ways,
one way i would use would be like:

for(int i=0;i<lstJonel.Items.Count;i++) {
if (lstJonel.Items[i].Selected==true)
Business.LogManager.LogEvent(lstJonel.Items[i].Value);
}//for
hope the code give you a hint on where to go from here.

regards,
Jonel
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: rob | last post by:
Here is my scenario: One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView. Then I have a database that has the columns Item1 and Item2 (among others) with the data type bit....
0
by: Agi Chen | last post by:
Hello, theres, I'm newbie in asp.net. I have problem in CheckBoxList binding to database. Considering my case in a member system, if I have 2 tables one for interest, one for memberInterest the...
2
by: ime | last post by:
Hi I don't know how to create connection between checkBoxList and a table from a database. When I run the application I want to see all the names from a table in a checkBoxList, and to check some...
3
by: Jack Black | last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages... Hi, all! I've been struggling with getting a dynamically-generated CheckBoxList generated. I've finally been able to get the...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
2
by: Patrick.O.Ige | last post by:
I have some boolean value(1 or 0 ) in a table and i want a databinded CheckBoxList to present the selected values on the page.. With CheckBox i know i can se the Checked property like so :-...
0
by: Nam | last post by:
I want to use the same sqlDataSource for two CheckBoxList controls in ASP.NET 2.0. For simplicity, I am using the case of only two CheckBoxList controls in the following example: My...
4
by: haresh.amis | last post by:
hello to all, I m using .net 2.0 and i face a problem that is as under Well I have a checkboxlist which i bound in .cs page now I want to count that how many checkboxes ate checked ( In...
1
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.