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
90
UltraWebGrid & WebCalcManager - Object reference not set to an instance of an object.
posted
I am receiving an error while binding my grid to an object from a click event off a button.  My Grid has 3 columns Price, Qty and Total.  Price and Qty are bound to the Price and Qty field in my class and total is a formula of Price * Qty.  The bands basetablename is bound to clsList set up in createBind().  If I remove the WebCalcManager, or change my object to a datatable everything works fine.
Here a quick example that shows the issue.

public partial class _Default : System.Web.UI.Page
{
   
protected void Page_Load(object sender, EventArgs e)
    {
       
LinkButton linkButton = new LinkButton();
        linkButton.ID =
"TestButton";
        linkButton.Text =
"Push Me";
        linkButton.Click +=
new EventHandler(LinkButton_Clicked);
        testDiv.Controls.Add(linkButton);
   
}
   
protected void LinkButton_Clicked(object sender, EventArgs e)
    {
        createBind();
    }
   
private void createBind()
    {
       
Class1 cls;
        System.Collections.Generic.
List<Class1> clsList = new System.Collections.Generic.List<Class1>();
       
for (int i = 1; i <= 5; i++)
        {
            cls =
new Class1();
            cls.Price = i * 50;
            cls.Qty = i * 2;
            clsList.Add(cls);
        }
       
this.UltraWebGrid1.DataSource = clsList;
       
this.UltraWebGrid1.DataBind();
    }
}

public class Class1
{
   
public int Price { get; set; }
   
public int Qty { get; set; }
}

 Here is the stack trace I receive.

NullReferenceException: Object reference not set to an instance of an object.]
   Infragistics.WebUI.UltraWebGrid.UltraCalc.RefCellCollectionEnumerator.MoveNext() +44
   Infragistics.WebUI.CalcEngine.RangeCalcInfo.EvaluateNextRow() +63
   Infragistics.WebUI.CalcEngine.UltraCalcEngine.Evaluate(Int64 ticks) +181
   Infragistics.WebUI.CalcEngine.UltraCalcEngine.Recalc(Int64 ticks) +215
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.ReCalcInternal(Int64 ticks, Boolean ignoreSuspend) +197
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.ReCalc(Int64 millis) +382
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.ReCalc(Boolean ignoreSuspend) +33
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.ReCalc() +33
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.ReCalcSynchronous() +54
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.VerifyReCalc() +54
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.DirtyCalc(IUltraCalcReference reference, ValueDirtiedAction action) +98
   Infragistics.WebUI.UltraWebCalcManager.UltraWebCalcManager.Infragistics.WebUI.CalcEngine.IUltraCalcManager.AddReference(IUltraCalcReference reference) +104
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.RegisterWithCalcManager() +187
   Infragistics.WebUI.UltraWebGrid.UltraGridLayout.ResumeCalcManagerNotifications() +234
   Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) +3461
   Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) +1926
   Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +1244
   GridTest._Default.createBind() in C:\Users\tlange\Documents\Visual Studio 2008\Projects\GridTest\Default.aspx.cs:47
   GridTest._Default.LinkButton_Clicked(Object sender, EventArgs e) in C:\Users\tlange\Documents\Visual Studio 2008\Projects\GridTest\Default.aspx.cs:30
   System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +90
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +76
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   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)

Does anybody have a fix for this issue?

Parents
No Data
Reply
  • 12333
    posted

     Hi Trent,

    I took your code and used it to make a sample web site. I made changes such that I am using ObjectDataSource and a class that returns a list of your custom business classes. I threw the working sample here:

    http://download.infragistics.com/users/TomP/WebGrid_WebCalcManager.zip

    My sample does not throw an exception. 

    Please download it, review the code and see if you can adapt this design to your application. You will have to use the project upgrade utility on this sample because I am using a version of the NetAdvantage assemblies that you may not have. The project upgrade utility will allow you to select the assemblies you have on your PC and it will update the sample's assembly references. Hope this helps. 

    Tom

Children