In my application i have multi selected dropdownlist and based on selection i need to display in gridview. If i select two items from multi select dropdown based on selected items i need to display records on gridview . In the below code i select two i am getting first selection records only.
protected void ddlcol2_SelectedIndexChanged(object sender, EventArgs e)
{
string qry = "select * from Collections where col1='" + ddlcol1.SelectedValue.ToString() + "' and col2='" + ddlcol2.SelectedValue.ToString() + "'";
SqlCommand cmd = new SqlCommand(qry,con);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
Gridview1.DataSource = dt;
Gridview1.DataBind();
}
ddlcol2 is the multi select dropdown if i select two items from ddlcol2 i want to display that two items records on gridview.
Can anyone please tell me to how to do this.
Thank you

Midhun TpRank #388 · 6.5K reputationPosted Sep 9, 2016, 12:28 AM EDT
{
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
Gridview1.DataSource = dt;
Gridview1.DataBind();
}
Vishal JadavRank #1,691 · 901 reputationPosted Sep 9, 2016, 12:15 AM EDT
User10728 reputationPosted Sep 9, 2016, 12:27 AM EDT
Vishal JadavRank #1,691 · 901 reputationPosted Sep 9, 2016, 1:52 AM EDT