Page 1 of 1

Admin -> Browse Catalog -> Choose Operation -> Error

Posted: Sat Apr 17, 2010 12:51 am
by Diavan
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.

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;
}
However .... it works with a little change.

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;
}

Re: Admin -> Browse Catalog -> Choose Operation -> Error

Posted: Sat Apr 17, 2010 8:30 am
by jmestep
There is a bug and mazhar posted a quick fix for it:
viewtopic.php?f=42&t=13091