Hi, we're using Infragistics 2007 Volume 1(.Net 1.1) and are trying to use paging on a screen with lots of data. On this screen you pick which view you want to display and any filter criteria that you may have and then click submit. Here's the events when you click submit:OnInit()Grid_InitializeDataSource()Grid_DataBinding()Grid_InitializeLayout()Grid_DataBinding()Grid_InitializeLayout()Page_Load()BtnSearch_Click()Grid_DataBinding()Grid_InitializeLayout()
Then when you click to go to the next page:OnInit()Grid_InitializeDataSource()Grid_DataBinding()Grid_InitializeLayout()Grid_DataBinding()Grid_InitializeLayout()Grid_DataBinding()Grid_InitializeLayout()Page_Load()Grid_PageIndexChanged()
The problem I'm having is that since InitializeDataSource is happening before Page_Load the view and filter criteria haven't been loaded back from the page yet so it first fetches the initial data. Then it fetches the data again with the selected criteria. Is there a way to get InitializeDataSource to happen after Page_Load? If i change it to only fetch 1 row in the InitializeDataSource paging and it displays an empty grid.
Invoke
paging.OnPageIndexChanged(paging.PageIndex);
during PreRender. Your PageIndexEvent hander will execute.
Does anyone have any ideas?
Rumen,Oh okay.
I have ViewState turned off because with a lot of data the page gets really large and our clients have trouble viewing it. The page is informational only so I don't have to worry about people changing the data on it. With ViewState on the paging will work correctly but I really need it to work with it turned off.
Here's sample code:private void Page_Load(object sender, System.EventArgs e) { btnSearch.Click += new EventHandler(btnSearch_Click);
if(IsPostBack == false) { FillSearchCriteria(); }
QueryModifiers qm = BuildFilterCondition(); if(qm != null) { BindGridData(userID, qm); } TeamOrdersGrid.DataBind(); } }override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // this.TeamOrderDetailsGrid.PageIndexChanged += new Infragistics.WebUI.UltraWebGrid.PageIndexChangedEventHandler(TeamOrderDetailsGrid_PageIndexChanged); this.TeamOrderDetailsGrid.InitializeLayout += new Infragistics.WebUI.UltraWebGrid.InitializeLayoutEventHandler(TeamOrderDetailsGrid_InitializeLayout); this.TeamOrderDetailsGrid.InitializeRow += new Infragistics.WebUI.UltraWebGrid.InitializeRowEventHandler(TeamOrderDetailsGrid_InitializeRow); this.TeamOrderDetailsGrid.DataBinding += new EventHandler(TeamOrderDetailsGrid_DataBinding);
InitializeComponent(); base.OnInit(e); }
private void BindGridData(decimal userID, QueryModifiers filterCondition) { OrderDetailBfo.LoadOrderRows(teamOrderBpoCol, filterCondition); }private void TeamOrderDetailsGrid_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { GridFilterBfo.FormatGridRows(e, userID, "TeamOrderDetails"); }private void TeamOrderDetailsGrid_DataBinding(object sender, EventArgs e) { TeamOrderDetailsGrid.DisplayLayout.AutoGenerateColumns = false;
//these 2 lines are needed for if one of the columns is grouped and the search button //is clicked TeamOrderDetailsGrid.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Flat; TeamOrderDetailsGrid.Bands.Clear();
GridFilterBfo.CreateGridColumns(TeamOrderDetailsGrid, "TeamOrderDetails");
TeamOrderDetailsGrid.DataSource = ((IListSource)teamOrderBpoCol).GetList(); } private void TeamOrderDetailsGrid_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e) { //turn on sum footer TeamOrderDetailsGrid.DisplayLayout.ColFootersVisibleDefault = Infragistics.WebUI.UltraWebGrid.ShowMarginInfo.Yes; GridFilterBfo.TurnOnSumFooterForCurrencies(TeamOrderDetailsGrid, "TeamOrderDetails"); TeamOrderDetailsGrid.AllowPaging = true; } protected void TeamOrderDetailsGrid_PageIndexChanged(object sender, Infragistics.WebUI.UltraWebGrid.PageEventArgs e) { TeamOrderDetailsGrid.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex; }I believe I sent all the relevent code if you need more detail on something let me know.
Hello Rob,
Sorry if what I said was confusing -- what I really meant to say is that InitializeDatasSource is convenient in many cases, but in the cases where you need to control when it fires and at what point at the page lifecycle it fires it's best to not use it since you really have no control on that.
If you are binding in Page_Load -- just make sure the grid has ViewState turned on and that you are not rebinding prior to firing the events (e.g. check for IsPostBack in Page_Load and bind only if it is false). Then, when PageIndexChanged fires, just change the CurrentPageIndex property and rebind the grid in the PageIndexChanged event handler.. If this does not help, could you please paste some source code -- this way it will be much easier for us to figure out what is going on.
Rumen,
Thanks for your reply. I'm confused by your post, you said that I should try not using the InitializeDataSource event but in the blog post it says i need to. I tried not using InitializeDataSource and instead filled the grid in the Page_Load event but then my PageIndexChanged event never got fired. I also tried it with InitializeDataSource event attached but not having it do anything.
Do you have any other suggestions?Thanks,Rob