Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkboxlist items staying selected

Status
Not open for further replies.

dpk136

MIS
Jan 15, 2004
335
US
I have a checkbox list that is populated dynamically (this part works fine). when a user selects a lot of the list I go through and check to see if the item is selected. If I select an item and go to the next page, then come back to the checkbox page and deselect the item, when i run the page it shows that the item has its selected property = true and it should be false. has anyone had this problem?

David Kuhn
------------------
 
1. if this is the asp:CheckBoxList forum855 would yield better results
2. without code we don't can't see what's happening
3. if i had to guess I would say the default values from the previous page are overwriting your current values.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Here is an example of what i do when the page is submitted (SaveColumns_Click)

Nothing is done with the Checkboxlist(cblColumns) before this.

Code:
  foreach (ListItem item in cblColumns.Items)
  {
    int iTestAttributeTypeKey;
    if (Int32.TryParse(item.Value, out iTestAttributeTypeKey))
    {
      //get the first row with the matching CASREPAttributeTypeKey
      ViewColumns.ViewColumnsRow [] vcRows = (ViewColumns.ViewColumnsRow []) dsViewColumns._ViewColumns.Select("TestAttributeTypeKey = " + item.Value);
      if (item.Selected)
      {
        //it goes in here when a item on the list has been deselected.  The page does not select these boxes when a page is submitted (form submit)
      }
    }
  }

David Kuhn
------------------
 
i didn't think TryParse worked with out the instaincing the variable. I could be wrong though.
Code:
int iTestAttributeTypeKey = 0;
if (Int32.TryParse(item.Value, out iTestAttributeTypeKey))
{
}
is [tt]ViewColumns[/tt] a custom object you use? i don't see where this is declared.

what is actually done within the [tt]if(item.selected)[/tt] statement?

is this wrapped in a try/catch block? if so is an exception caught before this loop is reached?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top