Hi Siby2000,
Here is a sample for filtering data from DropDownList control:
string query = "select * from table";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = GetData(query);
GridView1.DataBind();
}
}
public DataSet GetData(string query)
{
SqlConnection conn = new SqlConnection("Connection String");
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
return ds;
}
protected void Filter_Click(object sender, EventArgs e)
{
string id = SearchTextBox.Text;
if (id != "")
query = "select * from table where ID=" + id;
GridView1.DataSource = GetData(query);
GridView1.DataBind();
}
Other controls are similar to this, so you can try them by yourself. Remember to pass search text into query and then retrieve data to bind GridView.
Thanks,
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.