To show all rows in RadGrid. I want to give an option of "All" in RadGrid
PageSize Combo. Like this:
Solution:
VB Code
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
If TypeOf e.Item Is GridPagerItem Then
Dim combo As RadComboBox = TryCast(TryCast(e.Item, GridPagerItem).FindControl("PageSizeComboBox"), RadComboBox)
' The number of items shown when all is selected
Dim allRowsCount As Integer = Integer.MaxValue
' Remove duplicates
Dim duplicate As RadComboBoxItem = combo.Items.FindItemByValue(allRowsCount.ToString())
If duplicate IsNot Nothing Then
duplicate.Remove()
End If
' Create a new item for showing all
Dim item As New RadComboBoxItem("All", allRowsCount.ToString())
item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID)
combo.Items.Add(item)
' Set the current pagesize as the selected value
combo.Items.FindItemByValue(RadGrid1.PageSize.ToString()).Selected = True
End If
End Sub
If TypeOf e.Item Is GridPagerItem Then
Dim combo As RadComboBox = TryCast(TryCast(e.Item, GridPagerItem).FindControl("PageSizeComboBox"), RadComboBox)
' The number of items shown when all is selected
Dim allRowsCount As Integer = Integer.MaxValue
' Remove duplicates
Dim duplicate As RadComboBoxItem = combo.Items.FindItemByValue(allRowsCount.ToString())
If duplicate IsNot Nothing Then
duplicate.Remove()
End If
' Create a new item for showing all
Dim item As New RadComboBoxItem("All", allRowsCount.ToString())
item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID)
combo.Items.Add(item)
' Set the current pagesize as the selected value
combo.Items.FindItemByValue(RadGrid1.PageSize.ToString()).Selected = True
End If
End Sub