简体   繁体   English

在 mscorlib.dll 中发生 System.StackOverflowException 类型的未处理异常

[英]An unhandled exception of type System.StackOverflowException occurred in mscorlib.dll

I wrote a code in ASP.NET that read data from SQL Table and show it in Grid View and using Row Data Bound Event.But when I run the program, this exception arise "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll" in indicated statement of the code:我在 ASP.NET 中编写了一个代码,该代码从 SQL 表中读取数据并在网格视图中显示它并使用行数据绑定事件。但是当我运行程序时,出现此异常“mscorlib 中发生了“System.StackOverflowException”类型的未处理异常。 dll”在代码的指示语句中:

    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();

    }

The RowDataBoundEvent handler is: 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')");
    }

The BindAllUser Function is called here: BindAllUser Function 在这里被调用:

 protected void Page_Load(object sender, EventArgs e)
{
    BindAllUsers();
    BindDropDown();

}

Try this:尝试这个:

        private void BindAllUsers()
    {
        using (SqlConnection con = new SqlConnection("connection string"))
        {
            con.Open();
            SqlCommand command = new SqlCommand();
            command.Connection = con;
            command.CommandText = "SELECT ID, Name, Email, Password, Contact, CreatedOn, CreatedBy,CreatedIP From tbl_Users";
            SqlDataReader dr = command.ExecuteReader();
            if (dr.HasRows)
            {
                gdv_Users.DataSource = ds;
                gdv_Users.DataBind();
            }
        }

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mscorlib.dll中发生类型为&#39;System.StackOverflowException&#39;的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 发生mscorlib.dll错误时发生未处理的“System.StackOverflowException”类型异常? - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll error occurred? 调用递归函数期间,mscorlib.dll中发生了&#39;System.StackOverflowException&#39;类型的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll during calling recursive function WPF telerik TreeView控件中的mscorlib.dll发生类型为&#39;System.StackOverflowException&#39;的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in WPF telerik TreeView Control 在会话“ mscorlib.dll中发生类型&#39;System.StackOverflowException&#39;的未处理的异常”上 - on Session “An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll” 我只能序列化167条记录。 其他任何引发mscorlib.dll中发生了&#39;System.StackOverflowException&#39;类型的未处理异常 - I can serialize 167 records only. Any other throws An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 发生类型为“System.StackOverflowException”的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred VimService55.XmlSerializers.dll中发生未处理的“System.StackOverflowException”类型异常 - An unhandled exception of type 'System.StackOverflowException' occurred in VimService55.XmlSerializers.dll mscorlib.dll中发生类型为&#39;System.IO.IOException&#39;的未处理异常目录名称无效 - An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll The directory name is invalid 错误“mscorlib.dll中发生了&#39;System.IO.IOException&#39;类型的未处理异常” - Error “An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM