asp.net中用dropdownList实现查询功能代码

 string stype = ddlType.SelectedItem.Text;
            string strsql = "";
            switch (stype)
            {
                case "学号":
                    strsql = "select * from tb_Student where StudentNum like '%" + txtKey.Text.Trim() + "%'";
                    BaseClass.BindDG(gvStuInfo, "ID", strsql, "stuinfo"); ;
                    break;
                case "姓名":
                    strsql = "select * from tb_Student where StudentName like '%" + txtKey.Text.Trim() + "%'";
                    BaseClass.BindDG(gvStuInfo, "ID", strsql, "stuinfo");
                    break;
            }
原文地址:https://www.cnblogs.com/QiuJL/p/4524307.html