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
WayneWayne,
Instead of setting SelectedValue property of the list you should set
Selected property of every item you want to make selected.
Eliyahu
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:unBH1guHFHA.3196@.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
>
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" <removemeegoldin@.monarchmed.com> wrote in message
news:%23sD9ZxvHFHA.3076@.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" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:unBH1guHFHA.3196@.TK2MSFTNGP15.phx.gbl...
checked
> current
I
> to
and
something
say
>
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" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:ucyd6$xHFHA.576@.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" <removemeegoldin@.monarchmed.com> wrote in message
> news:%23sD9ZxvHFHA.3076@.tk2msftngp13.phx.gbl...
> checked
when
> I
syntax
> and
> something
> say
>
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" <removemeegoldin@.monarchmed.com> wrote in message
news:O5m29syHFHA.3928@.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" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:ucyd6$xHFHA.576@.TK2MSFTNGP15.phx.gbl...
> of
> All
> list.
> when
> syntax
items
to
>
It works! Thank you very much.
Wayne
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:u8R77zzHFHA.3760@.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" <removemeegoldin@.monarchmed.com> wrote in message
> news:O5m29syHFHA.3928@.TK2MSFTNGP09.phx.gbl...
lots
this.
the
> items
want
> to
>
Thursday, March 22, 2012
Marking CheckBoxList Items as Checked
Labels:
asp,
checkboxlist,
checkeditem,
collection,
created,
item,
items,
marking,
net,
record,
save,
sql
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment