C# 我在System.StackOverflowException未处理时收到此错误,HResult=-2147023895 Message=Exception\u被抛出内部异常:
System.StackOverflowException未经处理HResult=-2147023895 Message=Exception\u被抛出内部异常: 您正在调用bindgridview;从同一方法中。因此,它会一遍又一遍地调用自己,直到出现堆栈溢出C# 我在System.StackOverflowException未处理时收到此错误,HResult=-2147023895 Message=Exception\u被抛出内部异常:,c#,model-view-controller,C#,Model View Controller,System.StackOverflowException未经处理HResult=-2147023895 Message=Exception\u被抛出内部异常: 您正在调用bindgridview;从同一方法中。因此,它会一遍又一遍地调用自己,直到出现堆栈溢出 我不能从你的代码判断什么是合适的修复。你能从方法的底部删除那一行吗?或者您可能犯了一个错误,打算调用另一个方法。无论哪种方式,如果您调试应用程序并逐步完成代码,您将看到它一次又一次地进入该方法,而没有任何东西阻止它这样做。在codebin
我不能从你的代码判断什么是合适的修复。你能从方法的底部删除那一行吗?或者您可能犯了一个错误,打算调用另一个方法。无论哪种方式,如果您调试应用程序并逐步完成代码,您将看到它一次又一次地进入该方法,而没有任何东西阻止它这样做。在codebindgridview的末尾有一个额外的};在bindgridview方法的底部不需要。这是调试器的设计目的,这样您就可以调试并单步执行自己的代码。非常感谢您,我删除了这一行,现在代码正在运行。
public partial class dridviewinser_update_Delete : System.Web.UI.Page
{
string connectstringweb = ConfigurationManager.ConnectionStrings["mydatabase"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
bindgridview();
}
private void bindgridview()
{
//this is property
SqlConnection con = new SqlConnection(connectstringweb);
con.Open();
string query = "gridview_select_bindgrid";
SqlCommand cmd = new SqlCommand(query, con);
cmd.CommandType = CommandType.StoredProcedure;
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
grdviewdata.DataSource = dt;
grdviewdata.DataBind();
con.Close();
bindgridview();
}
protected void btninsert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(connectstringweb);
con.Open();
string query = "dridview_insert";
SqlCommand cmd = new SqlCommand(query, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", txtname);
cmd.Parameters.AddWithValue("@email", txtemail);
cmd.ExecuteNonQuery();
Response.Write("Insert Successfull!");
con.Close();
}
}
}