StringBuilder sbTemp=new StringBuilder();// sbTemp is used to build dynamic query.
//Check List Box has been dynamically filled with datatable at form load.
if (chkItem.CheckedItems.Count > 0)
{
sbTemp.Append(" AND ITEMID IN (");
foreach (DataRowView drv in chkItem.CheckedItems)
{
sbTemp.Append(drv[chkItem.ValueMember].ToString() + ",");
}
sbTemp.Remove(sbTemp.Length - 1, 1);
sbTemp.Append(")");
}