我在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