473,386 Members | 1,786 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,386 software developers and data experts.

CheckBoxList Not Retaining selections

I have a simple CheckBoxList like:

private void setChbSizes(int nProductID)
{
DataSet dsSizes;
dsSizes = dalSportPal.SizesByProductID(nProductID);
if(dsSizes.Tables[0].Rows.Count >= 0)
{
chbSizes.DataSource = dsSizes.Tables[0];
chbSizes.DataTextField = "ItemSize";
chbSizes.DataValueField = "SizeID";
chbSizes.DataBind();
}
}
When I call the following it's always true:
for ( int i=0; i < chbSizes.Items.Count; i++ )
{
if(chbSizes.Items[i].Selected == false)
{
// Do Something...
}
}

Anyone have a clue as to why my .Selected is always true?
Thanks in advance,
Brian K. Williams
Nov 18 '05 #1
2 1248
Brian,

Make sure that you call setChbSizes only if IsPostBack is false. Also check
if you enable ViewState.

Eliyahu

"Brian K. Williams" <wi*******@millenia.com> wrote in message
news:eM*************@TK2MSFTNGP11.phx.gbl...
I have a simple CheckBoxList like:

private void setChbSizes(int nProductID)
{
DataSet dsSizes;
dsSizes = dalSportPal.SizesByProductID(nProductID);
if(dsSizes.Tables[0].Rows.Count >= 0)
{
chbSizes.DataSource = dsSizes.Tables[0];
chbSizes.DataTextField = "ItemSize";
chbSizes.DataValueField = "SizeID";
chbSizes.DataBind();
}
}
When I call the following it's always true:
for ( int i=0; i < chbSizes.Items.Count; i++ )
{
if(chbSizes.Items[i].Selected == false)
{
// Do Something...
}
}

Anyone have a clue as to why my .Selected is always true?
Thanks in advance,
Brian K. Williams

Nov 18 '05 #2
It's always something simple that you just can't at the end of a 15 hour
day. The next morning I noticed that I forgot the !IsPostback, it was
re-writing everything on every post.

Thanks
-Brian

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

Make sure that you call setChbSizes only if IsPostBack is false. Also check if you enable ViewState.

Eliyahu

"Brian K. Williams" <wi*******@millenia.com> wrote in message
news:eM*************@TK2MSFTNGP11.phx.gbl...
I have a simple CheckBoxList like:

private void setChbSizes(int nProductID)
{
DataSet dsSizes;
dsSizes = dalSportPal.SizesByProductID(nProductID);
if(dsSizes.Tables[0].Rows.Count >= 0)
{
chbSizes.DataSource = dsSizes.Tables[0];
chbSizes.DataTextField = "ItemSize";
chbSizes.DataValueField = "SizeID";
chbSizes.DataBind();
}
}
When I call the following it's always true:
for ( int i=0; i < chbSizes.Items.Count; i++ )
{
if(chbSizes.Items[i].Selected == false)
{
// Do Something...
}
}

Anyone have a clue as to why my .Selected is always true?
Thanks in advance,
Brian K. Williams


Nov 18 '05 #3

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

Similar topics

1
by: Dennis Johansson | last post by:
I have a CheckBoxList like this one: <asp:CheckBoxList id="chkReport" runat="server" DataValueField="rptID" DataTextField="RptName" Enabled="False" RepeatLayout="Flow"></asp:CheckBoxList> I...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
0
by: Jensen bredal | last post by:
Hello, I have a CheckboxList that is bound to a table in my database. I want to display information from my product table based on the choices made on the CheckBoxList. The the primary key of...
1
by: Lynn | last post by:
Hello, I have a page that allows the person to select multiple items from a checkboxlist. The checkboxlist is being populated from a table in the database. The user's selections are sent to the...
1
by: Zak | last post by:
Hello, I need some help trying to grab the data selected from a checkboxlist. The checklist is acting like a menu. The first selection is accepted but not the multiple ones. For example is the...
0
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
In VS2008, I have a DetailsView control with a checkboxlist control inside its Edit template. (1) I want the checkboxlist to be dynamic and display only as many checkboxes as a user setting is...
5
by: deepakthegeek | last post by:
I dont know if this kind of issue has been addressed earlier. I have a gridview control on a form, in the EditItem Template when a textbox is clicked, I have a popupcontrolextender displaying an...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.