public void GetItemsbyFacilityID(string FacilityID)
        {
            InventoryServiceClient      lclsservice = new InventoryServiceClient();
            List <GetItemsbyFacilityID> lstfac      = lclsservice.GetItemsbyFacilityID(Convert.ToInt64(FacilityID)).ToList();

            foreach (var lst in lstfac)
            {
                foreach (ListItem drplst in drdItemID.Items)
                {
                    if (drplst.Value == lst.ItemID.ToString())
                    {
                        if (lst.IsActive == true)
                        {
                            drdItemID.Items.FindByText(drplst.Text).Selected = true;
                            HddItemActive.Value += drplst.Value + '/' + 1 + ',';
                        }
                        else
                        {
                            HddItemActive.Value += drplst.Value + '/' + 0 + ',';
                        }
                    }
                }
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         //div_AddContent.Visible = false;
         InventoryServiceClient service = new InventoryServiceClient();
         BALFaItemMap           obj     = new BALFaItemMap();
         //if (ViewState["FacilityItemID"] != null)
         if (hiFacilityItemID.Value != null)
         {
             obj.FacilityItemMapID = Convert.ToInt64(hiFacilityItemID.Value);
         }
         InventoryServiceClient      lclsservice = new InventoryServiceClient();
         List <GetItemsbyFacilityID> lstfac      = lclsservice.GetItemsbyFacilityID(Convert.ToInt64(drdItemID.SelectedValue)).ToList();
         if (lstfac.Count == 0)
         {
             foreach (ListItem drplst in drdItemID.Items)
             {
                 if (drplst.Selected == true)
                 {
                     HddItemActive.Value += drplst.Value + '/' + 1 + ',';
                 }
             }
         }
         else
         {
             HddItemActive.Value = HddItemActive.Value.Substring(0, (HddItemActive.Value.Length - 1));
             string[] SplitID = HddItemActive.Value.Split(',');
             HddItemActive.Value = "";
             for (int i = 0; i < SplitID.Length; i++)
             {
                 string[] SplitTempID = SplitID[i].Split('/');
                 foreach (ListItem drplst in drdItemID.Items)
                 {
                     if (drplst.Value == SplitTempID[0].ToString())
                     {
                         if (drplst.Selected == true)
                         {
                             HddItemActive.Value += drplst.Value + '/' + 1 + ',';
                         }
                         else
                         {
                             HddItemActive.Value += drplst.Value + '/' + 0 + ',';
                         }
                     }
                     else if (drplst.Selected == true)
                     {
                         HddItemActive.Value += drplst.Value + '/' + SplitTempID[1].ToString() + ',';
                     }
                 }
             }
             HddItemActive.Value = HddItemActive.Value.Substring(0, (HddItemActive.Value.Length - 1));
             string[] DupSplit = HddItemActive.Value.Split(',');
             HddItemActive.Value = "";
             RemoveDuplicates(DupSplit);
         }
         HddItemActive.Value = HddItemActive.Value.Substring(0, (HddItemActive.Value.Length - 1));
         obj.ItemID          = HddItemActive.Value.ToString();
         obj.FacilityID      = Convert.ToInt64(ddlFacilityID.SelectedValue);
         obj.CreatedBy       = Convert.ToInt64(Session["User"]);
         obj.CreatedOn       = DateTime.Now;
         string    lstrmsg = service.InsertUpdateFacilityItemMap(obj);
         Functions objfun  = new Functions();
         objfun.MessageDialog(this, "Saved Successfully");
         ScriptManager.RegisterStartupScript(this, typeof(Page), "anything", "clear();", true);
         HddItemActive.Value = "";
         BindGrid();
         clearDropDown();
     }
     catch
     {
     }
 }