Vikas Ahlawat

Vikas Ahlawat

  • NA
  • 564
  • 809.3k

Problem in Column Filter.

Apr 11 2011 4:39 AM
I have the list of checkbox according to these checkbox i want to filter the datatable
for this i have write the following code

            foreach (ListItem lstItm in chklist_Companyfilter.Items)
            {
                if (lstItm.Selected == true)
                {
                   
                    QueryCompany += "\""+lstItm.Value+ "\",";    // it gives result as "city","state"
                  
                }

            }
          if (QueryCompany != "")
            {
                QueryCompany = QueryCompany.Substring(0, QueryCompany.Length - 1);
            }
            Session["ColumnsNames"] = QueryCompany;

now i am passing this in the next page where i need to filter the table according to these column names


if (Session["ColumnsNames"] != null)
                        {
                           
                            DataView dv = new DataView(ds.Tables[0]);
                            string s = Session["ColumnsNames"].ToString();
 DataTable dt = dv.ToTable(true,s); 
// it gives error but i put it static as DataTable dt = dv.ToTable(true, "asd","fdas"); then working
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                            ds.Clear();
                            dt.Clear();
                            Session["Result"] = null;
                        }


Please help me how can i filter the columns ?


Answers (1)