我有一个带分页的数据列表,可以很好地进行本地调试,但不能在我的托管公司提供的部署服务器上运行。
Line 151: TotalRowCount = pagedData.DataSourceCount;
我在本地和部署服务器上使用相同的远程数据库。
错误讯息:
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
答案 0 :(得分:2)
这意味着从服务器到数据库的连接不起作用,因为pagedData对象为null。
检查您是否可以使用正确的身份访问您的数据源。