Hi..thank u for all your wonderful forum posts. it helped me a lot.
My question is I have multiple Checkbox Lists and i want to compare it and Filter Datalist records on Checkbox list checked event.. (I want filtering something like http://www.jabong.com/men/shoes/men-sports-shoes/?source=topnav#/men/shoes/men-sports-shoes/adidas-golf--Asics/?forder=brand--sh_size&sh_size=7--8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BindList();
}
}
private void BindList()
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string query = "SELECT * FROM Customers";
string condition = string.Empty; foreach (ListItem item in chkCountries.Items)
{
condition += item.Selected ? string.Format("'{0}',", item.Value) : "";
}
if (!string.IsNullOrEmpty(condition))
{
condition = string.Format(" where Country in ({0})", condition.Substring(0, condition.Length - 1));
}
SqlCommand cmd = new SqlCommand(query + condition); using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con; sda.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
sda.Fill(ds);
DataList1.DataSource = ds;
Label1.Text = ds.Tables[0].Rows.Count.ToString();
DataList1.DataBind();
sda.Fill(ds);
}
}
}
}
protected void City_Selected(object sender, EventArgs e)
{
this.BindList();
}
protected void Country_Selected(object sender, EventArgs e)
{
this.BindList();
}
}
My problem is If first checkbox list is checked and user clicks on second checkbox list then i want to compare both checkboxes and populate result based on both checkboxes. pls help me!