473,406 Members | 2,387 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,406 software developers and data experts.

Marking CheckBoxList Items as Checked

I have a CheckBoxList with 11 items in the collection. I save the checked
item to a SQL DB, A record is created for each item checked for the current
customer.I want to redisplay checks in the fields that contain 1's when I
retrieve the records for that customer but I can't figure out the syntax to
do that? The chkList1.SelectedValue property deselects all other items and
the Items property appears to only accept an index. How can I do something
like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say
to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
.......

End Select
End While

Thanks

Wayne
Nov 19 '05 #1
7 1834
Wayne,

Instead of setting SelectedValue property of the list you should set
Selected property of every item you want to make selected.

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
I have a CheckBoxList with 11 items in the collection. I save the checked
item to a SQL DB, A record is created for each item checked for the current customer.I want to redisplay checks in the fields that contain 1's when I
retrieve the records for that customer but I can't figure out the syntax to do that? The chkList1.SelectedValue property deselects all other items and
the Items property appears to only accept an index. How can I do something
like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say
to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
......

End Select
End While

Thanks

Wayne

Nov 19 '05 #2
Thanks for the reply.

Exactly how do I do that? I cannot figure out the syntax. There are lots of
choices in the Intellisense but nothing that makes sense to me for this. All
I want to do is to set the checkbox as checked for named values in the list.

Wayne
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Wayne,

Instead of setting SelectedValue property of the list you should set
Selected property of every item you want to make selected.

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
I have a CheckBoxList with 11 items in the collection. I save the checked item to a SQL DB, A record is created for each item checked for the

current
customer.I want to redisplay checks in the fields that contain 1's when I retrieve the records for that customer but I can't figure out the syntax

to
do that? The chkList1.SelectedValue property deselects all other items and the Items property appears to only accept an index. How can I do something like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
......

End Select
End While

Thanks

Wayne


Nov 19 '05 #3
This syntax seems to work:
cbList1.Items.Item("GE Music").Selected = True

The big confusion is that when you are keying in the statement and get to
the "Item" the popup indicates that it must be a zero based index. I did not
realize I could enter the value there.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
I have a CheckBoxList with 11 items in the collection. I save the checked
item to a SQL DB, A record is created for each item checked for the current customer.I want to redisplay checks in the fields that contain 1's when I
retrieve the records for that customer but I can't figure out the syntax to do that? The chkList1.SelectedValue property deselects all other items and
the Items property appears to only accept an index. How can I do something
like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say
to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
......

End Select
End While

Thanks

Wayne

Nov 19 '05 #4
When I load that out to my web site and run it I get the error:

Exception Details: System.FormatException: Input string was not in a correct
format.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:OQ**************@tk2msftngp13.phx.gbl...
This syntax seems to work:
cbList1.Items.Item("GE Music").Selected = True

The big confusion is that when you are keying in the statement and get to
the "Item" the popup indicates that it must be a zero based index. I did not realize I could enter the value there.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
I have a CheckBoxList with 11 items in the collection. I save the checked item to a SQL DB, A record is created for each item checked for the

current
customer.I want to redisplay checks in the fields that contain 1's when I retrieve the records for that customer but I can't figure out the syntax

to
do that? The chkList1.SelectedValue property deselects all other items and the Items property appears to only accept an index. How can I do something like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
......

End Select
End While

Thanks

Wayne


Nov 19 '05 #5
Something like this (C# syntax):
public void SetCheckedForValue (CheckBoxList cbl, string val)
{
for (int i=0; i<cbl.Count; i++)
if (cbl.Items[i].Value==val)
{
cbl.Items[i].Selected=true;
return;
}
}

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uc*************@TK2MSFTNGP15.phx.gbl...
Thanks for the reply.

Exactly how do I do that? I cannot figure out the syntax. There are lots of choices in the Intellisense but nothing that makes sense to me for this. All I want to do is to set the checkbox as checked for named values in the list.
Wayne
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Wayne,

Instead of setting SelectedValue property of the list you should set
Selected property of every item you want to make selected.

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
I have a CheckBoxList with 11 items in the collection. I save the checked item to a SQL DB, A record is created for each item checked for the current
customer.I want to redisplay checks in the fields that contain 1's
when I retrieve the records for that customer but I can't figure out the
syntax
to
do that? The chkList1.SelectedValue property deselects all other items

and the Items property appears to only accept an index. How can I do something like:

While datareader1.Read
Select Case Category
Case "Gets Mailers"
cbList1.SelectedValue = "Gets Mailers" <== I really want to say to check that selection
Case "Store Card"
cbList1.SelectedValue = "Store Card"
......

End Select
End While

Thanks

Wayne



Nov 19 '05 #6
Eliyahu;

Thank you. I think I understand what needs to be done now. I'll try this and
let you know the results.

Wayne

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Something like this (C# syntax):
public void SetCheckedForValue (CheckBoxList cbl, string val)
{
for (int i=0; i<cbl.Count; i++)
if (cbl.Items[i].Value==val)
{
cbl.Items[i].Selected=true;
return;
}
}

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uc*************@TK2MSFTNGP15.phx.gbl...
Thanks for the reply.

Exactly how do I do that? I cannot figure out the syntax. There are lots

of
choices in the Intellisense but nothing that makes sense to me for this.

All
I want to do is to set the checkbox as checked for named values in the

list.

Wayne
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Wayne,

Instead of setting SelectedValue property of the list you should set
Selected property of every item you want to make selected.

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:un**************@TK2MSFTNGP15.phx.gbl...
> I have a CheckBoxList with 11 items in the collection. I save the

checked
> item to a SQL DB, A record is created for each item checked for the
current
> customer.I want to redisplay checks in the fields that contain 1's when
I
> retrieve the records for that customer but I can't figure out the syntax to
> do that? The chkList1.SelectedValue property deselects all other

items and
> the Items property appears to only accept an index. How can I do

something
> like:
>
> While datareader1.Read
> Select Case Category
> Case "Gets Mailers"
> cbList1.SelectedValue = "Gets Mailers" <== I really want
to say
> to check that selection
> Case "Store Card"
> cbList1.SelectedValue = "Store Card"
> ......
>
> End Select
> End While
>
> Thanks
>
> Wayne
>
>



Nov 19 '05 #7
It works! Thank you very much.

Wayne

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:u8**************@TK2MSFTNGP12.phx.gbl...
Eliyahu;

Thank you. I think I understand what needs to be done now. I'll try this and let you know the results.

Wayne

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Something like this (C# syntax):
public void SetCheckedForValue (CheckBoxList cbl, string val)
{
for (int i=0; i<cbl.Count; i++)
if (cbl.Items[i].Value==val)
{
cbl.Items[i].Selected=true;
return;
}
}

Eliyahu

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:uc*************@TK2MSFTNGP15.phx.gbl...
Thanks for the reply.

Exactly how do I do that? I cannot figure out the syntax. There are lots
of
choices in the Intellisense but nothing that makes sense to me for
this.
All
I want to do is to set the checkbox as checked for named values in the list.

Wayne
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Wayne,
>
> Instead of setting SelectedValue property of the list you should set
> Selected property of every item you want to make selected.
>
> Eliyahu
>
> "Wayne Wengert" <wa***************@wengert.com> wrote in message
> news:un**************@TK2MSFTNGP15.phx.gbl...
> > I have a CheckBoxList with 11 items in the collection. I save the
checked
> > item to a SQL DB, A record is created for each item checked for

the > current
> > customer.I want to redisplay checks in the fields that contain 1's

when
I
> > retrieve the records for that customer but I can't figure out the

syntax
> to
> > do that? The chkList1.SelectedValue property deselects all other

items and
> > the Items property appears to only accept an index. How can I do
something
> > like:
> >
> > While datareader1.Read
> > Select Case Category
> > Case "Gets Mailers"
> > cbList1.SelectedValue = "Gets Mailers" <== I really
want to say
> > to check that selection
> > Case "Store Card"
> > cbList1.SelectedValue = "Store Card"
> > ......
> >
> > End Select
> > End While
> >
> > Thanks
> >
> > Wayne
> >
> >
>
>



Nov 19 '05 #8

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

Similar topics

4
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
3
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception...
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 :-...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
2
by: EnjoyLife | last post by:
I am new to ASP.NET and am trying to learn it the best that I can. I am trying to add some code in the If IntRowIndex > -1 statement to mark an item SELECTED before adding it to the CheckBoxList. ...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
2
by: clintonG | last post by:
When selected="true" is declared in the CheckBoxList ListItem FireFox does not display checked list items. Even more curious is the absence of the checked="checked" attribute in the source which is...
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...
3
by: onlyprad | last post by:
Hi, I am populating the checkboxlist in (!IsPostBack) block of page load event with some checked items. After populating with checked items I am iterating through the items collection and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.