ASP.NET做检索系统遇到的问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 18:15:38
我在用ASP.NET做检索系统时遇到的问题:下面是搜索页面(search.aspx)的处理页面(search.aspx.cs),我现在要在sousuoxinxi.aspx页面用GridView和SqldataSource来显示用户所要的信息,应该怎么做?

public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

String zhutici = Request.Form.Get("TextBox1");

String aim = DropDownList1.SelectedValue;

String sqlconn = "server=localhost;uid=sa;pwd=gao;database=VS2007;Trusted_Connection=no";
SqlConnection myConnection = new SqlConnection(sqlconn);
//打开数据库
myConnection.Open();
if( aim =="标题")
sql = "select * from Thesis where Thesis_title='" + zhutici + "'";
else if( aim=="作者")
sql = "select * from Thesis where Thesis_aut

protected void Button1_Click(object sender, EventArgs e)
{

string sql;
String zhutici = Request.Form.Get("TextBox1");

String aim = DropDownList1.SelectedValue;

String sqlconn = "server=localhost;uid=sa;pwd=gao;database=VS2007;Trusted_Connection=no";
SqlConnection myConnection = new SqlConnection(sqlconn);
//打开数据库
myConnection.Open();
if (aim == "标题")
sql = "select * from Thesis where Thesis_title='" + zhutici + "'";
else if (aim == "作者")
sql = "select * from Thesis where Thesis_author='" + zhutici + "'";
else if (aim == "种属")
sql = "select * from Thesis where Thesis_type='" + zhutici + "'";