Hi Mahesh,
Here is the code for you.
string strQuery = "SELECT * FROM Your_Table WHERE Your_First_Condition";
string strWhere = string.Empty;
// Now you have your checkboxes for cities.
if( chkCity1.Checked)
{
strWhere = "(City = '" + chkCity1.Text + "'";
}
if( chkCity2.Checked)
{
if (strWhere == string.Empty)
strWhere = "(City = '" + chkCity1.Text + "'";
else
strWhere = strWhere + " or City = '" + chkCity2.Text + "'";
}
if( chkCity3.Checked)
{
if (strWhere == string.Empty)
strWhere = "(City = '" + chkCity3.Text + "'";
else
strWhere = strWhere + " or City = '" + chkCity3.Text + "'";
}
if( chkCity4.Checked)
{
if (strWhere == string.Empty)
strWhere = "(City = '" + chkCity4.Text + "'";
else
strWhere = strWhere + " or City = '" + chkCity4.Text + "'";
}
// At last complete the bracket
if(strWhere != string.Empty)
{
strWhere = strWhere + ")";
//Now add this to main query..
strQuery = strQuery + " and " + strWhere;
}
Now your query is ready. You can run it.
Hope this helps.