locked
Object reference not set to an instance of an object. RRS feed

  • Question

  • User-1759624489 posted

    Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 11: //// dynamically build the context key so the web service knows which table we're talking about Line 12: //autoComplete1.ContextKey = fkColumn.ParentTable.Provider.DataModel.ContextType.FullName + "#" + fkColumn.ParentTable.Name; Line 13: autoComplete1.ContextKey = AutocompleteFilterService.GetContextKey(fkColumn.ParentTable);

     

    Hello.  I am trying to setup autocomplete filter.

     

     [MetadataType(typeof(AssetMetaData))]
        public partial class Asset
        {
           
        }

        [DisplayName("Activo")]
        public class AssetMetaData
        {
            public object Id { get; set; }
           
            [DisplayName("Nombre Activo")]
            [Required(ErrorMessage = "Este campo es Requerido")]
            [Filter(FilterControl="Autocomplete")]
            public object Name { get; set; }

    Monday, September 8, 2008 10:23 AM

Answers

  • User1641955678 posted

    The auto-complete filter only works on relationship columns, and I'm guessing that's the the case of your Name column.  Of course, error handling should be better, but that's a side issue.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 8, 2008 1:20 PM

All replies

  • User1641955678 posted

    Where is the null ref exception happening?  Could you include the full stack?

    thanks,
    David

    Monday, September 8, 2008 11:39 AM
  • User-1759624489 posted

     

     

     Its on the first line., fkColumn becomes null, so the second line doesnt work.

           var fkColumn = Column as MetaForeignKeyColumn;

                //// dynamically build the context key so the web service knows which table we're talking about
                //autoComplete1.ContextKey = fkColumn.ParentTable.Provider.DataModel.ContextType.FullName + "#" + fkColumn.ParentTable.Name;
                autoComplete1.ContextKey = AutocompleteFilterService.GetContextKey(fkColumn.ParentTable);
    and the full stack is this one.

     

    <title>Object reference not set to an instance of an object.</title><style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style>

    Server Error in '/WebSite' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 11:             //// dynamically build the context key so the web service knows which table we're talking about
    Line 12:             //autoComplete1.ContextKey = fkColumn.ParentTable.Provider.DataModel.ContextType.FullName + "#" + fkColumn.ParentTable.Name;
    Line 13:             autoComplete1.ContextKey = AutocompleteFilterService.GetContextKey(fkColumn.ParentTable);
    Line 14: 
    Line 15:             // add javascript to create postback when user selects an item in the list

    Source File: c:\Inetpub\wwwroot\WebSite\DynamicData\Filters\Autocomplete.ascx.cs    Line: 13

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Autocomplete_Filter.Page_Init(Object sender, EventArgs e) in c:\Inetpub\wwwroot\WebSite\DynamicData\Filters\Autocomplete.ascx.cs:13
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnInit(EventArgs e) +99
       System.Web.UI.UserControl.OnInit(EventArgs e) +77
       System.Web.UI.Control.InitRecursive(Control namingContainer) +333
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
       System.Web.UI.ControlCollection.Add(Control child) +80
       Microsoft.Web.DynamicData.DelegatingFilter.Page_Init(Object sender, EventArgs e) in D:\Luis\Sodexho\CDS Bancolombia\CdsBancolombia\CDSBancolombia\DynamicDataFutures0716\DynamicData\Futures\Controls\DelegatingFilter.cs:44
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnInit(EventArgs e) +99
       System.Web.UI.UserControl.OnInit(EventArgs e) +77
       System.Web.UI.Control.InitRecursive(Control namingContainer) +333
       System.Web.UI.Control.InitRecursive(Control namingContainer) +210
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
       System.Web.UI.ControlCollection.Add(Control child) +80
       System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +106
       System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +443
       System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +51
       System.Web.UI.WebControls.Repeater.DataBind() +75
       System.Web.DynamicData.FilterRepeater.DataBind() +22
       System.Web.DynamicData.FilterRepeater.Page_InitComplete(Object sender, EventArgs e) +37
       System.EventHandler.Invoke(Object sender, EventArgs e) +0
       System.Web.UI.Page.OnInitComplete(EventArgs e) +8694646
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +467
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
    <!-- [NullReferenceException]: Object reference not set to an instance of an object. at Autocomplete_Filter.Page_Init(Object sender, EventArgs e) in c:\Inetpub\wwwroot\WebSite\DynamicData\Filters\Autocomplete.ascx.cs:line 13 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at Microsoft.Web.DynamicData.DelegatingFilter.Page_Init(Object sender, EventArgs e) in D:\Luis\Sodexho\CDS Bancolombia\CdsBancolombia\CDSBancolombia\DynamicDataFutures0716\DynamicData\Futures\Controls\DelegatingFilter.cs:line 44 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.Repeater.DataBind() at System.Web.DynamicData.FilterRepeater.DataBind() at System.Web.DynamicData.FilterRepeater.Page_InitComplete(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Page.OnInitComplete(EventArgs e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.dynamicdata_custompages_assets_listdetails_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website\92deab70\f27760e2\App_Web_eqlxunai.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --> 

    Monday, September 8, 2008 12:07 PM
  • User1641955678 posted

    The auto-complete filter only works on relationship columns, and I'm guessing that's the the case of your Name column.  Of course, error handling should be better, but that's a side issue.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 8, 2008 1:20 PM