protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeinsightsupplier":
                {
                    int insightSupplierId = Convert.ToInt32(e.CommandArgument);

                    InsightSupplierCustomHeader.DeleteInsightSupplierCustomHeaderByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionLink.DeleteInsightSupplierContactDistributionLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionOption.DeleteInsightSupplierContactDistributionOptionByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionModel.DeleteInsightSupplierContactDistributionModelByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactLicense.DeleteInsightSupplierContactLicenseByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactLink.DeleteInsightSupplierContactLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplierMerchandising.DeleteInsightSupplierMerchandisingByInsightSupplierId(insightSupplierId);
                    InsightSupplierMerchSupplierLink.DeleteInsightSupplierMerchSupplierLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplier.DeleteInsightSupplierByInsightSupplierId(insightSupplierId);

                    BindGridViewResultDefault();

                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
            }
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                InsightSupplierCustomHeader customHeader = new InsightSupplierCustomHeader();
                customHeader.InsightSupplierCustomHeaderId = this.insightSupplierCustomHeaderId;
                customHeader.InsightSupplierId             = this.insightSupplierId;
                customHeader.Description  = TextBoxCustomDetail.Text;
                customHeader.StatusId     = 1; //Always Active.
                customHeader.ModifiedUser = Context.User.Identity.GetUserName();

                try
                {
                    customHeader.Save();
                    //int insightSupplierId = customHeader.InsightSupplierId;

                    if (SaveInsightSupplierCustomDetail() == false)
                    {
                        return;
                    }

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSaveNew":
                        Response.Redirect(String.Format("InsightSupplierCustomEdit.aspx?InsightSupplierId={0}", this.insightSupplierId));
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />");
                        //LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    //PanelError.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.insightSupplierId = Common.GetEncryptedQueryStringValue("InsightSupplierId", 0);

            InsightSupplierCustomHeader customHeader = InsightSupplierCustomHeader.GetInsightSupplierCustomHeaderByInsightSupplierId(this.insightSupplierId);

            this.customHeaderDescription       = customHeader.Description;
            this.insightSupplierCustomHeaderId = customHeader.InsightSupplierCustomHeaderId;

            LabelPageTitle.Text = String.Format("{0} - CUSTOM", InsightSupplier.GetInsightSupplierByInsightSupplierId(this.insightSupplierId).SupplierName);

            Page.Form.DefaultFocus  = TextBoxCustomDetail.ClientID;
            Page.Form.DefaultButton = ButtonSaveNew.UniqueID;

            if (!IsPostBack)
            {
                TextBoxCustomDetail.Focus();
                ButtonSaveNew.Visible = true;

                BindCustomType();
                BindCustomFrequency();
                BindCustomResponsibility();
                BindStatus();

                if (ViewState["InsightSupplierId"] != null)
                {
                    this.insightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"].ToString());
                }

                if (this.insightSupplierId != 0)
                {
                    BindInsightSupplierCustomHeader();
                    BindGridViewCustomDetail();
                }
            }
        }