Admin -> Browse Catalog -> Choose Operation -> Error
Posted: Sat Apr 17, 2010 12:51 am
Under "Admin -> Browse Catalog" (Browse.aspx) if any Category contains products count more than GridView PageSize (default=40) than the paging links will show up on top and bottom for that category.
If you navigate to any page above Page '1' - then select any number of products using the checkboxes - after that try to use any bulk operation from dropdown (<choose operation>) - I get error every time on the code below.
Can someone confirm this please. Many thanks.
However .... it works with a little change.
If you navigate to any page above Page '1' - then select any number of products using the checkboxes - after that try to use any bulk operation from dropdown (<choose operation>) - I get error every time on the code below.
Can someone confirm this please. Many thanks.
Code: Select all
protected List<DataKey> GetSelectedItems()
{
List<DataKey> selectedItems = new List<DataKey>();
foreach (GridViewRow row in CGrid.Rows)
{
CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "Selected");
if ((selected != null) && selected.Checked)
{
int index = row.DataItemIndex - (CGrid.PageIndex * CGrid.PageSize);
selectedItems.Add(CGrid.DataKeys[index]); // *ERROR* - index always negative for page '2' and above
}
}
return selectedItems;
}
Code: Select all
protected List<DataKey> GetSelectedItems()
{
List<DataKey> selectedItems = new List<DataKey>();
foreach (GridViewRow row in CGrid.Rows)
{
CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "Selected");
if ((selected != null) && selected.Checked)
{
int index = row.DataItemIndex; // - (CGrid.PageIndex * CGrid.PageSize);
selectedItems.Add(CGrid.DataKeys[index]); // *WORKS*
}
}
return selectedItems;
}