public void BindCategory(string mode) { try { InventoryServiceClient lclsservice = new InventoryServiceClient(); foreach (ListItem lst in drpfacilitysearch.Items) { if (lst.Selected && drpfacilitysearch.SelectedValue != "All") { SB.Append(lst.Value + ','); } } if (SB.Length > 0) { FinalString = SB.ToString().Substring(0, (SB.Length - 1)); } drpcategorysearch.DataSource = lclsservice.GetCategoryByListFacilityID(FinalString).ToList();; drpcategorysearch.DataValueField = "CategoryID"; drpcategorysearch.DataTextField = "CategoryName"; drpcategorysearch.DataBind(); foreach (ListItem lst in drpcategorysearch.Items) { lst.Attributes.Add("class", "selected"); lst.Selected = true; } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.EndingInventoryErrorMessage.Replace("<<EndingInventory>>", ex.Message), true); } }