Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Null Reference on Fillcolumns from dynamic grid
posted

Hi all,

I am experiencing some weird behaviour with some dynamically created controls. I'm not sure if it's a grid issue or a tab issue or a dynamically created control issue but please bare with me. 

The scenario is the I have an ultrawebtab to display accounts and on page_init a method is called that adds a new tab for every account.

Each dynamic account tab contains a usercontrol I have created. This usercontrol contains an ultrawebtab whose tabs contain ultrawebgrids. Data is retrieved from the database and datatables from the returning dataset populate the grids.

The strange behaviour is with these grids. Firstly, they don't automatically resolve the datasource layout so I have to specify UltraGridColumns in the UltraGridBand - where usually this is unnecessary when doing a straight DataBind(). If the columns are not specified no rows appear after DataBind().

Secondly, if there are no rows in the datasource table there is a nullreference exception:

 [NullReferenceException: Object reference not set to an instance of an object.]
   Infragistics.WebUI.UltraWebGrid.DBBinding.FillColumns(UltraWebGrid grid, UltraGridBand currentBand, IEnumerable datasource) +4361
   Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) +293
   Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) +1610
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +513
   Reports_Parts_ucPortfolioReview.BindPortfolioReview(DataSet dsPortfolioReview) in c:\Projects\ForceWEB\PlatformServices\WebSites\DevelopmentWebsite\Reports\Parts\ucPortfolioReview.ascx.cs:30
   Reports_PortfolioReview.btnViewReviewReport_Click(Object sender, ButtonEventArgs e) in c:\Projects\ForceWEB\PlatformServices\WebSites\DevelopmentWebsite\Reports\PortfolioReview.aspx.cs:128
   Infragistics.WebUI.WebDataInput.WebImageButton.OnClick(Int32 action) +139
   Infragistics.WebUI.WebControls.Buttons.WebButtonBase.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

So there seems to be some going on with the columns. Is this some kind of initialisation issue from the dynamically created controls. I'd rather not have to bother with the ultragridcolumns and have the grids working the way they naturally do.

Can anyone provide any insight as to what is going on and how it can be made to work properly?

Giddyup.