基本linkbutton使用之“查询”

来源:互联网 发布:java jsonstring转map 编辑:程序博客网 时间:2024/05/08 07:08

用linkbutton在repeater 的中查询数据的代码:

protected void LinkCX_Click1(object sender, EventArgs e)

        {
            if (T_xh.Text == "")
            {
                ScriptManager.RegisterStartupScript(Repeater1,this.GetType(),"updatescript","alert('学号不能为空!!')",true);
            }
            else
            {
                DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.sqlcon, CommandType.Text, "select * from View_jbxx_bmxx where jbxx_xh=" + T_xh.Text);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    ScriptManager.RegisterStartupScript(Repeater1, this.GetType(), "updatescript", "alert('请输入正确的学号!!')", true);
                }
                else
                {
                   
                    Repeater1.DataSource = ds.Tables[0];
                    Repeater1.DataBind();
                }






            }


        }