我在ASP.NET中編寫了一個代碼,它從SQL Table讀取數據並在Grid View中顯示並使用Row Data Bound Event.But在運行該程序時,在mscorlib.dll中發生未處理的System.StackOverflowException異常
private void BindAllUsers()
{
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Name, Email, Password, Contact, CreatedOn, CreatedBy,CreatedIP From tbl_Users",con);
DataSet ds = new DataSet();
da.Fill(ds); <------(Error occurs in this line)
gdv_Users.DataSource = ds;
gdv_Users.DataBind();
}
的RowDataBoundEvent處理程序是:
protected void gdv_Users_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Style["Cursor"] = "hand";
e.Row.Cells[0].ToolTip = "Click Here";
e.Row.Cells[0].Attributes.Add("onclick","window.open('Details.aspx'?ID=" + e.Row.Cells[0].Text.ToString()+"'Details';'width = 735,height= 350,left = 220,top = 300,resizable = 0,scrollbars = 0,status = no')");
}
的BindAllUser功能是此異常的代碼所示聲明出現「類型‘System.StackOverflowException’mscorlib.dll中發生未處理的異常」這裏叫:
protected void Page_Load(object sender, EventArgs e)
{
BindAllUsers();
BindDropDown();
}
你怎麼在Visual Studio調用堆棧看? – SLaks
我想你是在OnRowDataBoundEvent中調用BindAllUsers,並且因爲你正在使網格重新陷入無限循環。你能發佈RowDataaBound事件處理程序嗎? – Chandu
@Rachit:你還可以在你調用BindAllUsers方法的地方發佈代碼嗎? – Chandu