未将对象引用设置到对象的实例????高手请进
建立一个button名字为Button1,建立事件 Button1_Click,
private void Button1_Click(object sender, System.EventArgs e)
{
int CurrentPageNum=0;
try
{
CurrentPageNum=threads.CurrentPageIndex;
threads.CurrentPageIndex=Convert.ToInt32(TBPageNum.Text);
BindData();
}
catch
{
threads.CurrentPageIndex=CurrentPageNum;
BindData();
}
}
运行时,出现错误提示:未将对象引用设置到对象的实例。
什么意思?
具体出错信息如下:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 173: this.threads.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.threads_PageIndexChanged_1);
行 174: this.threads.SelectedIndexChanged += new System.EventHandler(this.threads_SelectedIndexChanged);
行 175: this.Button1.Click += new System.EventHandler(this.Button1_Click);
行 176: this.Load += new System.EventHandler(this.Page_Load);
行 177:
源文件: G:\web\bbs2\display2.aspx.cs 行: 175
堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
Project1.display2.InitializeComponent() in G:\web\bbs2\display2.aspx.cs:175
Project1.display2.OnInit(EventArgs e) in G:\web\bbs2\display2.aspx.cs:161
System.Web.UI.Control.InitRecursive(Control namingContainer) +241
System.Web.UI.Page.ProcessRequestMain() +174
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
谢谢高手回答