When I programmatically add a grid in the Page Init event, I understand how I can create the paging and it works.
However if the grid is not created in the Page Init, but in the Ribbon Buttonclicked event the paging command on the grid is not working. How should I enable this.
Private
Sub
ribbon_ButtonClick(sender
As
Object
, e
As
Telerik.Web.UI.RibbonBarButtonClickEventArgs)
Handles
ribbon.ButtonClick
Dim
radGrid =
New
RadGrid()
With
{
.AllowCustomPaging =
True
,
.AllowFilteringByColumn =
True
,
.AllowPaging =
True
,
.AllowSorting =
True
,
.AutoGenerateColumns =
True
,
.ID =
"myGrid"
,
.PageSize = 4,
.ShowGroupPanel =
True
,
.ShowStatusBar =
True
,
.VirtualItemCount = 20,
.Width = Unit.Percentage(95)
}
AddHandler
radGrid.NeedDataSource,
Sub
(_sender
As
Object
, _e
As
GridNeedDataSourceEventArgs) RefreshData(
CType
(_sender, RadGrid))
AddHandler
radGrid.PageIndexChanged,
Sub
(_sender
As
Object
, _e
As
GridPageChangedEventArgs) RefreshData(
CType
(_sender, RadGrid))
AddHandler
radGrid.PageSizeChanged,
Sub
(_sender
As
Object
, _e
As
GridPageSizeChangedEventArgs) RefreshData(
CType
(_sender, RadGrid))
phGrid.Controls.Add(radGrid)
RadAjaxManager.AjaxSettings.AddAjaxSetting(radGrid, radGrid)
End
Sub
Private
Sub
RefreshData(grid
As
RadGrid)
grid.DataSource =
New
List(Of
String
)({grid.CurrentPageIndex, grid.PageSize})
End
Sub