Click here to Skip to main content
16,011,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my code if i select any one check box means it shows correct value in grid view.
but if i select both means it shows additonal values except i bound the values
in grid view based on search results in previous page.,

C#
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();
Posted
Updated 2-May-12 4:40am
v2
Comments
Sandeep Mewara 2-May-12 9:35am    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
ZurdoDev 2-May-12 10:40am    
added code tag

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900