protected void GetTemplateDetails()
        {
            iPartRequestClient   objService = new iPartRequestClient();
            mRequestTemplateHead ReqTmpHead = new mRequestTemplateHead();

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();
                ReqTmpHead = objService.GetTemplateOrderHead(Convert.ToInt64(hdnTemplateID.Value), profile.DBConnection._constr);

                long SiteID = Convert.ToInt64(ReqTmpHead.Department); hdnselectedDept.Value = SiteID.ToString(); Session["DeptID"] = SiteID.ToString();

                iUCCommonFilterClient objCommon = new iUCCommonFilterClient();
                long CompanyID = objCommon.GetCompanyIDFromSiteID(SiteID, profile.DBConnection._constr);

                txtTitle.Text = ReqTmpHead.TemplateTitle.ToString();
                ddlAccessType.SelectedValue = ReqTmpHead.Accesstype.ToString();

                //ddlCompany.SelectedIndex = ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(ReqTmpHead.Customer.ToString()));
                //cmp = long.Parse(ReqTmpHead.Customer.ToString());
                List <mCompany> CompanyLst = new List <mCompany>();
                string          UserType   = profile.Personal.UserType.ToString();
                long            UID        = profile.Personal.UserID;

                if (UserType == "Admin")
                {
                    //  CompanyLst = objService.GetCompanyName(profile.DBConnection._constr).ToList();
                    // CompanyLst = objService.GetUserCompanyName(UID, profile.DBConnection._constr).ToList();

                    CompanyLst = objCommon.GetUserCompanyNameNEW(UID, profile.DBConnection._constr).ToList();
                }
                else if (UserType == "User" || UserType == "Requester And Approver" || UserType == "Requester" || profile.Personal.UserType == "Requestor" || profile.Personal.UserType == "Requestor And Approver")
                {
                    CompanyLst = objCommon.GetUserCompanyName(UID, profile.DBConnection._constr).ToList();
                }
                else
                {
                    CompanyLst = objCommon.GetCompanyName(profile.DBConnection._constr).ToList();
                }
                ddlCompany.DataSource = CompanyLst;
                ddlCompany.DataBind();

                ddlCompany.SelectedIndex = ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(CompanyID.ToString())); //ddlCompany.Items.IndexOf(ddlCompany.Items.FindByValue(ReqTmpHead.Customer.ToString()));
                cmp = CompanyID;

                int Cmpny = int.Parse(CompanyID.ToString());  //Convert.ToInt16(ReqTmpHead.Customer.ToString());
                ddlSites.DataSource = WMGetDept(Cmpny);
                ddlSites.DataBind();
                ddlSites.SelectedIndex = ddlSites.Items.IndexOf(ddlSites.Items.FindByValue(ReqTmpHead.Department.ToString()));
                dpt = long.Parse(ReqTmpHead.Department.ToString());

                txtRemark.Text = ReqTmpHead.Remark.ToString();

                //ddlAddress.DataSource = WMGetDeptAddress(CompanyID); //WMGetDeptAddress(SiteID);
                //ddlAddress.DataBind();
                //ddlAddress.SelectedIndex = ddlAddress.Items.IndexOf(ddlAddress.Items.FindByValue(ReqTmpHead.Address.ToString()));
                //adrs = long.Parse(ReqTmpHead.Address.ToString());

                //ddlContact1.DataSource = WMGetContactPersonLst(CompanyID); //WMGetContactPersonLst(SiteID);
                //ddlContact1.DataBind();
                //ddlContact1.SelectedIndex = ddlContact1.Items.IndexOf(ddlContact1.Items.FindByValue(ReqTmpHead.Contact1.ToString()));
                //c1 = long.Parse(ReqTmpHead.Contact1.ToString());
                ////ddlContact2.DataSource = WMGetContactPerson2Lst(Convert.ToInt64(ReqTmpHead.Department), Convert.ToInt64(ddlContact1.SelectedIndex));
                //ddlContact2.DataSource = WMGetContactPerson2Lst(CompanyID, Convert.ToInt64(ddlContact1.SelectedIndex));
                //ddlContact2.DataBind();
                //ddlContact2.SelectedIndex = ddlContact2.Items.IndexOf(ddlContact2.Items.FindByValue(ReqTmpHead.Contact2.ToString()));
                //c2 = long.Parse(ReqTmpHead.Contact2.ToString());

                //lblAddress.Text = ddlAddress.SelectedItem.ToString();

                DataSet dsTemplatePartLst = new DataSet();
                dsTemplatePartLst = objService.GetTemplatePartLstByTemplateID(Convert.ToInt64(hdnTemplateID.Value), profile.DBConnection._constr);
                List <POR_SP_GetPartDetail_ForRequest_Result> TemplatePartList = new List <POR_SP_GetPartDetail_ForRequest_Result>();
                if (dsTemplatePartLst.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i <= dsTemplatePartLst.Tables[0].Rows.Count - 1; i++)
                    {
                        TemplatePartList = objService.AddPartIntoRequest_TempData(dsTemplatePartLst.Tables[0].Rows[i]["PrdID"].ToString(), Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, SiteID, profile.DBConnection._constr).ToList();
                        string uom = objService.GetUOMName(Convert.ToInt64(dsTemplatePartLst.Tables[0].Rows[i]["UOMID"].ToString()), profile.DBConnection._constr);
                        POR_SP_GetPartDetail_ForRequest_Result PartRequest = new POR_SP_GetPartDetail_ForRequest_Result();
                        PartRequest.Sequence      = i + 1;
                        PartRequest.RequestQty    = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Qty"].ToString()); // Convert.ToDecimal(dictionary["RequestQty"]);
                        PartRequest.Price         = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Price"].ToString());
                        PartRequest.Total         = Convert.ToDecimal(dsTemplatePartLst.Tables[0].Rows[i]["Total"].ToString());
                        PartRequest.IsPriceChange = Convert.ToInt16(dsTemplatePartLst.Tables[0].Rows[i]["IsPriceChange"].ToString());
                        PartRequest.UOMID         = Convert.ToInt64(dsTemplatePartLst.Tables[0].Rows[i]["UOMID"].ToString());
                        PartRequest.UOM           = uom;

                        objService.UpdatePartRequest_TempData12(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);
                        // objService.UpdatePartRequest_TempData(HttpContext.Current.Session.SessionID, ObjectName, profile.Personal.UserID.ToString(), PartRequest, profile.DBConnection._constr);

                        TemplatePartList = objService.GetExistingTempDataBySessionIDObjectName(Session.SessionID, profile.Personal.UserID.ToString(), ObjectName, profile.DBConnection._constr).ToList();
                    }
                }

                Grid1.DataSource = TemplatePartList;
                Grid1.DataBind();
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "Request Template", "GetTemplateDetails");
            }
            finally { objService.Close(); }
        }