String sqlText = Session["grid"].ToString(); // here the bounded value //session[grid] contains following query.. (Select airlineimg,stops,departure_time,arrival_time,duration,price from DomesticAirlines where departure='" + txt_dep_date.Text.Trim() + "' AND origin='" + txt_origin.Text.Trim() + "' AND destination='" + txt_dest.Text.Trim() + "'") String sqlFilterText = ""; int index = 0; foreach (ListItem item in chbklist1.Items) { index += 1; if (item.Selected) { String paramName = "@airlines_id" + index.ToString().Trim(); //String paramName = "@airlines_id"; SqlParameter param = new SqlParameter(paramName, SqlDbType.Int); param.Value = item.Value.Trim(); cmd.Parameters.Add(param); sqlFilterText += " airlines_id = " + paramName + " or "; } } if (!String.IsNullOrEmpty(sqlFilterText)) { sqlText += " AND " + sqlFilterText.Substring(0, sqlFilterText.Length - 3); } cmd.CommandText = sqlText; cmd.Connection = cnn; SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable tbl = new DataTable(); adapter.Fill(tbl); GridView1.DataSource = tbl; GridView1.DataBind();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)