CS0116:命名空间不能直接包含字段或方法等成员

时间:2016-08-01 01:29:25

标签: asp.net button

单击时按钮的事件处理程序出现此错误。请帮我。提前谢谢!

HTMLCODE

<asp:Button ID="RunButton" runat="server" Text="Run" onclick="Load"/>

服务器代码

protected void btn_Click(object sender, EventArgs e)
    {
    string strConnString = ConfigurationManager.ConnectionStrings["SQL"].ConnectionString;
    using (SqlConnection con = new SqlConnection(strConnString))
    {
        using (SqlCommand cmd = new SqlCommand("SELECT * FROM [dbo].[Emp]"))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;
                sda.SelectCommand = cmd;
                using (DataTable dt = new DataTable())
                {
                    sda.Fill(dt);
                    ResultPage.GridView1.DataSource = dt;
                    ResultPage.GridView1.DataBind();
                }
            }
        }
    }
}

0 个答案:

没有答案