I create a Grid on server-side on button click event.
The grid has been created fine, but the mfunctionality of the grid doesn't work.
For example, I am trying to change page size, but the event isn't fired.
Here is my code:
protected void btnGenerate_Click(object sender, EventArgs e)
{
PopulateGrid();
}
protected void PopulateGrid()
{
GridPlaceHolder.Controls.Clear();
RadGrid GridReport = new RadGrid();
GridReport.GroupingSettings.CaseSensitive =
false;
GridReport.ID =
"GridReport";
GridReport.Skin =
"Gray";
GridReport.EnableViewState =
false;
GridReport.MasterTableView.EnableColumnsViewState =
false;
GridReport.Width =
Unit.Pixel(1413);
GridReport.Height =
Unit.Pixel(550);
GridReport.AllowPaging =
true;
GridReport.AllowSorting =
true;
GridReport.PageSize = 10;
GridReport.MasterTableView.AllowCustomPaging =
true;
GridReport.AutoGenerateColumns =
false;
GridReport.AllowFilteringByColumn =
false;
GridReport.EnableLinqExpressions =
false;
GridReport.GridLines =
GridLines.None;
GridReport.NeedDataSource +=
new GridNeedDataSourceEventHandler(this.GridReport_NeedDataSource);
GridReport.PageIndexChanged +=
new GridPageChangedEventHandler(this.GridReport_PageIndexChanged);
GridReport.PagerStyle.Mode =
GridPagerMode.NextPrevNumericAndAdvanced;
GridReport.ClientSettings.Scrolling.AllowScroll =
true;
GridReport.ClientSettings.Scrolling.UseStaticHeaders =
true;
GridReport.ClientSettings.Resizing.AllowColumnResize =
true;
GridReport.ClientSettings.Resizing.EnableRealTimeResize =
true;
GridReport.MasterTableView.AllowSorting =
true;
GridReport.MasterTableView.AllowNaturalSort =
false;
GridReport.MasterTableView.HierarchyLoadMode =
GridChildLoadMode.ServerOnDemand;
GridReport.ClientSettings.AllowExpandCollapse =
true;
GridReport.MasterTableView.TableLayout =
GridTableLayout.Fixed;
GridReport.MasterTableView.Width =
Unit.Pixel(1413);
GridReport.FilterMenu.EnableAjaxSkinRendering =
true;
GridReport.ClientSettings.AllowColumnsReorder =
false;
GridReport.ClientSettings.AllowDragToGroup =
false;
GridReport.ClientSettings.ReorderColumnsOnClient =
true;
GridReport.ClientSettings.Resizing.ResizeGridOnColumnResize =
true;
GridReport.ClientSettings.Resizing.ClipCellContentOnResize =
true;
GridReport.ClientSettings.EnableRowHoverStyle =
true;
GridReport.ClientSettings.ClientEvents.OnRowSelected =
"RowSelected";
GridReport.ClientSettings.Selecting.AllowRowSelect =
true;
LoadReport(GridReport);
GridPlaceHolder.Controls.Add(GridReport);
}
private void LoadReport(RadGrid GridReport)
{
string reportName = "Report_Operations";
switch (reportName )
{
case "Report_Operations":
GridReport.MasterTableView.DataKeyNames =
new string[] { "OperationID" };
GridReport = BLL.BO.Reports.
Operations.GenerateReportColumns(ref GridReport);
break;
}
private void GridReport_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
//do something
GridReport.DataSource = dt;}
void GridReport_PageIndexChanged(object source, GridPageChangedEventArgs e)
{
// DO SOMETHING, HERE THE BREAKPOINT NEVER HITS!
}
Thanks for your help!