类风湿不遗传 2016-09-26 06:23 采纳率: 33.3%
浏览 1336
已采纳

asp.net程序中 单击buttn按钮没有响应其后台的单击事件

前台:

 <form id="form1" runat="server" action="./Demo2.aspx">
        <div>
            <table style="height: 326px; width: 935px">
                <tr>
                    <td class="auto-style3">キーワード検索:
                        <asp:TextBox ID="SelectText" runat="server" Width="428px" Height="16px" Text="社員氏名をローマ字または漢字で検索してください"></asp:TextBox>
                        &nbsp;
                        <asp:Button ID="SelectBtn" runat="server" Text="検索" Width="103px" OnClick="SelectBtn_Click" />
 后台:
    protected void SelectBtn_Click(object sender, EventArgs e)
        {
            string sqlCon = "Data Source=tcp:m7pevx6s1h.database.windows.net;Initial Catalog=srpnotesdev02;User ID=o365wp@m7pevx6s1h;Password=P@ssw0rd!;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";
            SqlConnection scon = new SqlConnection(sqlCon);
            if (scon.State != ConnectionState.Open)
            {
                scon.Open();
            }
            string sql;

            string text = this.SelectText.Text.ToString();
            string parm = @"[/^[a-zA-Z]+$/]";
            Regex rg = new Regex(parm);
            Match mh = rg.Match(text);
            if (mh.Success)
            {
                sql = " select EName,UniqueNo,jno,name,GroupSName_1,GroupSName_2,GroupSName_3,O365_Email from MainForm where EName='" + this.SelectText.Text.ToString() + "'  ";


            }
            else
            {
                sql = " select EName,UniqueNo,jno,name,GroupSName_1,GroupSName_2,GroupSName_3,O365_Email from MainForm where name='" + this.SelectText.Text.ToString() + "'  ";


            }
            SqlCommand scmd = new SqlCommand(sql, scon);
            SqlDataAdapter sda = new SqlDataAdapter(scmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            Console.WriteLine(dt);
            Rept.DataSource = dt;
            Rept.DataBind();
        }



    }
}

  • 写回答

1条回答 默认 最新

  • 类风湿不遗传 2016-09-26 06:24
    关注
                                                这个是前台
    
     <form id="form1" runat="server" action="./Demo2.aspx">
            <div>
                <table style="height: 326px; width: 935px">
                    <tr>
                        <td class="auto-style3">キーワード検索:
                            <asp:TextBox ID="SelectText" runat="server" Width="428px" Height="16px" Text="社員氏名をローマ字または漢字で検索してください"></asp:TextBox>
                            &nbsp;
                            <asp:Button ID="SelectBtn" runat="server" Text="検索" Width="103px" OnClick="SelectBtn_Click" />
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致