When I enable the option to display "ALL" records int he grid, it is working. But when I add one more item with the ALL option selected, it throws an error.
Following code is my workaround. With this code, with ALL selected, when I add a new item, it goes to the second page, though all items shouls fit in the first page itself ( I have less than 50 items).
Following code is my workaround. With this code, with ALL selected, when I add a new item, it goes to the second page, though all items shouls fit in the first page itself ( I have less than 50 items).
protected
void rgProjects_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
bool ALLSelected = (dropDown.SelectedItem.Text == "ALL") ? true : false;
var sizes = new Dictionary<string, string>()
{
{
"50", "50"},
{
"100", "100"},
{
"200", "200"}
};
sizes.Add(
"All", totalCount.ToString());
dropDown.Items.Clear();
foreach (var size in sizes)
{
var cboItem = new RadComboBoxItem()
{
Text = size.Key,
Value = size.Value
};
cboItem.Attributes.Add(
"ownerTableViewId", e.Item.OwnerTableView.ClientID);
dropDown.Items.Add(cboItem);
}
try
{
if (ALLSelected)
dropDown.FindItemByValue(totalCount.ToString()).Selected =
true;
else
{
RadComboBoxItem item = dropDown.FindItemByValue(rgProjects.PageSize.ToString());
if (item != null) item.Selected = true;
}
}
catch (Exception ex)
{
ShowValidationMessage(ex.Message);
}
}
}