Hey guys,
I have a grid in a web user control that implements:
UltraWebGrid1.InitializeDataSource += new Infragistics.WebUI.UltraWebGrid.InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);
UltraWebGrid1_InitializeDataSource queries the database, gets a datatable object and assigns it to the grid's datasource.
everything works fine.
However if I add the WebNavBar:
<ignavbar:webnavbar id="WebNavBar1" runat="server" > <Extension Visible="false" > </Extension> <Navigation Next-AutoPostBack="false" Prev-AutoPostBack= "false" End-AutoPostBack="false" Start-AutoPostBack="false" Rewind-AutoPostBack="false" FastForward-AutoPostBack="false" ></Navigation></ignavbar:webnavbar>
protected override void OnInit(EventArgs e) { UltraWebGrid1.InitializeDataSource += new Infragistics.WebUI.UltraWebGrid.InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource); WebNavBar1.GridID = UltraWebGrid1.UniqueID; }
and click Reverse or Forward I would get the following exception (all other buttons work just fine):
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.WebUI.UltraWebGrid.RowsCollection.Infragistics.WebUI.UltraWebGrid.IXPathDataNavigable.GetFirstChild() +183 Infragistics.WebUI.UltraWebGrid.RowsCollection.Infragistics.WebUI.UltraWebGrid.IXPathDataNavigable.get_HasChildren() +32 Infragistics.WebUI.UltraWebGrid.XPathDataNavigator.OutputToStream(XPathDataNavigator xpdn, XmlTextWriter stream, HtmlTextWriter htmlWriter) +142 Infragistics.WebUI.UltraWebGrid.RenderXmlGrid.WriteBody(HtmlTextWriter writer, RowsCollection rows, Boolean topLevel) +112 Infragistics.WebUI.UltraWebGrid.RenderXmlGrid.WriteUltraWebGrid(HtmlTextWriter writer, UltraWebGrid grid, Boolean shouldWriteAll) +418 Infragistics.WebUI.UltraWebGrid.RenderXmlGrid.VisitObjects(HtmlTextWriter output) +603 Infragistics.WebUI.Shared.RendererBase.Render(HtmlTextWriter output) +36 Infragistics.WebUI.UltraWebGrid.GridRendererBase.Render(HtmlTextWriter output) +482 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.Render(HtmlTextWriter output) +336 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +236 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +32 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20 System.Web.UI.Page.Render(HtmlTextWriter writer) +26 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558
I had a similar problem with another grid and I solved it reassigning the datasource to the grid on these events:
onaftermovenext="WebNavBar1_Move" onaftermoveprev="WebNavBar1_Move" onaftermovetoend="WebNavBar1_Move" onaftermovetostart="WebNavBar1_Move"
I haven't had the same luck with this grid.
Can somebody help please?
Thanks !
ureyes84 said:changing the value of Browser from "Xml" to "Auto" will "fix" it. However, it makes the grid look weird the first time it loads
I noticed this keeps the app from crashing when clicking the WebNavBar, however, as stated above, the grid will render differently when the page is refreshed.
This is an email I got from Nick, which fixed my problem, so I hope this helps someone else.
--------------------------------------
Hm, this seems to be a bug in the Grid, here is an easy workaround:
<igtbl:UltraWebGrid ID="UWGrdProjects" runat="server" Width="100%" Height="140px" Browser="Auto">
<DisplayLayout LoadOnDemand="Xml" SelectTypeRowDefault="Single">
<HeaderStyleDefault
CssClass=""
Font-Names="Verdana, Arial, Helvetica, sans-serif"
Font-Size="11px"
BackColor="#D4D7DB"
BackgroundImage="App_Themes/Default/Office2007Blue/WebGrid/igwgHeader.jpg">
<Padding Left="10px" Right="10px" />
</HeaderStyleDefault>
<Pager AllowPaging="true" PageSize="5" ></Pager>
</DisplayLayout>
</igtbl:UltraWebGrid>
The idea is to put a HeaderStyleDefault section below DisplayLayout and set its CssClass to Empty, then set Font, BackGround, Padding etc. however you like.
thanks Nick.
The page where my grid is contains multiple UpdatePanel controls. I noticed after removing them, the grid was keeping the active row selected. I'm still getting the exception when:
Browser="Xml" LoadOnDemand="Xml"
So any help would be appreciated.
Ok now I'm getting the exception again.
Setting
will make the app crash , even with the DataBind on the OnAfterMoveBackward
changing the value of Browser from "Xml" to "Auto" will "fix" it. However, it makes the grid look weird the first time it loads
So is this a bug? or is it just that these settings are incompatible with the navbar?
hey thanks !, now it seems to work better, I thought I did this before.... weird.
Anyway, there is still something.
After adding your code and running the application If you change the page using the Forward or the Reverse button and then click the Next or the Previous button, it won't change the active row, or at least it won't select it, even if I add:
protected void WebNavBar1_ChangeActiveRow(object sender, Infragistics.WebUI.WebNavBar.AfterNavigateEventArgs args) { UWGrdProjects.DisplayLayout.ActiveRow.Selected = true; }
OnAfterMoveNext="WebNavBar1_ChangeActiveRow" OnAfterMovePrev="WebNavBar1_ChangeActiveRow"
UPDATE: Clicking the Forward and the Reverse buttons will change the page. but for some reason when I click the Next or Previous buttons it will highlight the row in the previous page, I found out this by going back to the previous page after clicking the Next or Previous buttons.
any ideas?
thanks again for your help !!
void WebNavBar1_AfterMoveBackward(object sender, Infragistics.WebUI.WebNavBar.AfterNavigateEventArgs args){ UWGrdProjects.DataBind();}
void WebNavBar1_AfterMoveForward(object sender, Infragistics.WebUI.WebNavBar.AfterNavigateEventArgs args){ UWGrdProjects.DataBind();}
Hope that helps.
Best,Nick