Tutorial :paging count error asp.net



Question:

I have a data list with paging which works fine locally debugging but doesn't work on my deployment server provided by my hosting company.

Line 151:        TotalRowCount = pagedData.DataSourceCount;  

I'm using the same remote database for both local and on deployment server.

Error message:

Server Error in '/' 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 149:  Line 150:        // Remember the total number of records being paged through across postbacks  Line 151:        TotalRowCount = pagedData.DataSourceCount;  Line 152:        PrevPage.Visible = !pagedData.IsFirstPage;  Line 153:        NextPage.Visible = !pagedData.IsLastPage;      Source File: \\pdc1\sites\t\test.domain.com\public_html\Auctions.aspx.cs    Line: 151    Stack Trace:    [NullReferenceException: Object reference not set to an instance of an object.]     Auctions.ItemDataSource_Selected(Object sender, ObjectDataSourceStatusEventArgs e) in \\pdc1\sites\t\test.domain.com\public_html\Auctions.aspx.cs:151     System.Web.UI.WebControls.ObjectDataSourceView.OnSelected(ObjectDataSourceStatusEventArgs e) +95     System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +432     System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1247     System.Web.UI.WebControls.BaseDataList.GetData() +38     System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +153     System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54     System.Web.UI.WebControls.BaseDataList.DataBind() +55     System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60     System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69     System.Web.UI.Control.EnsureChildControls() +87     System.Web.UI.Control.PreRenderRecursiveInternal() +44     System.Web.UI.Control.PreRenderRecursiveInternal() +171     System.Web.UI.Control.PreRenderRecursiveInternal() +171     System.Web.UI.Control.PreRenderRecursiveInternal() +171     System.Web.UI.Control.PreRenderRecursiveInternal() +171     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842      Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053   


Solution:1

This implies the connection to your database from the server isn't working, as the pagedData object is null.

Check you can access your datasource, with the correct identity.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »