C# 通过文本框过滤数据列表,DropDownList一无所获
我正在开发一个应用程序,我想在其中添加搜索,我在我的页面上使用一个数据列表,并希望对其进行过滤。我做了我的搜索,但当我点击搜索按钮时显示空白页面C# 通过文本框过滤数据列表,DropDownList一无所获,c#,asp.net,C#,Asp.net,我正在开发一个应用程序,我想在其中添加搜索,我在我的页面上使用一个数据列表,并希望对其进行过滤。我做了我的搜索,但当我点击搜索按钮时显示空白页面 protected void Button1_Click(object sender, EventArgs e) { string coom = ConfigurationManager.ConnectionStrings["COMM"].ConnectionString; string q = "select * from Pla
protected void Button1_Click(object sender, EventArgs e)
{
string coom = ConfigurationManager.ConnectionStrings["COMM"].ConnectionString;
string q = "select * from Place where Name Like '%" + TextBox1.Text + "%' AND Comments Like '%" + DropDownList1.SelectedItem.Text + "%'";
SqlConnection connection = new SqlConnection(coom);
connection.Open();
SqlCommand cmd = new SqlCommand(q, connection);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
我已经填了3个小时了,但不知道问题出在哪里
请帮忙!感谢尝试调试
TextBox1.Text
,DropDownList1.SelectedItem.Text
是否有值,使用从TextBox1.Text
和DropDownList1.SelectedItem.Text
获得的值在SQL上运行字符串命令。如果它有记录返回,请检查您的数据集
您是否调试并检查查询是否返回任何数据?您是否将数据列表绑定到页面加载中的任何数据源?谢谢!