ASP.NET C# Dropdown selected index firing on button click
Problem description:

See the screen attached.The exporter dropdown selected index changed is fired on button save click for some reason.Another strange thing happening is that the textbox & checkbox value inside gridview are lost which I guess is because gridview is populated everytime the selected index is changed.Please advise....

Problem is I am not able to capture the checbox and texbox values at any point...
Goal is to save the textbox values inside in the database but the checkbox and textbox are always false and blank respectively.




HTML 
Exporter ddl

<asp:DropDownList ID="ddlExporter" runat="server" AutoPostBack="true" OnSelectedIndexChanged="GetExporterLicences_OnSelectedIndexChanged" InitialValue="-1" >
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator ID="rqExporter" ControlToValidate="ddlExporter" ValidationGroup="bolDetails"
                                                        InitialValue="-1" SetFocusOnError="true" Text="*" runat="server"></asp:RequiredFieldValidator>



Gridview

  <cc1:OgisGridView ID="ExporterGrid" runat="server" CssClass="mGrid" AutoGenerateColumns="false"
                                                        Width="100%" DataKeyNames="ExportLicenseId" OnRowCreated="ExporterGrid_RowCreated" 
                                                        OnRowDataBound="ExporterGrid_RowDataBound">
                                                        <HeaderStyle CssClass="gridHeader" />
                                                        <RowStyle CssClass="gridRow" HorizontalAlign="Left"  />
                                                        <AlternatingRowStyle CssClass="gridAlternative" />
                                                        <Columns>
                                                        <asp:TemplateField>
                                                        

                                                                 <ItemTemplate>
                                                                    <asp:CheckBox ID="chkExportLicense" runat="server"  />
                                                                </ItemTemplate>
                                                            </asp:TemplateField>

                                                            <asp:BoundField DataField="ExportLicenseNumber" HeaderText="Export licence no." ItemStyle-HorizontalAlign="Right" />
                                                            <asp:BoundField DataField="IssueDate" HeaderText="Issue date" ItemStyle-HorizontalAlign="Center" />
                                                            <asp:BoundField DataField="ExpireDate" HeaderText="Expiry date" ItemStyle-HorizontalAlign="Center" />
                                                            <asp:BoundField DataField="LicensedQuantity" HeaderText="Licence quantity" ItemStyle-HorizontalAlign="Right" />
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtLiftingGrossQuantity" runat="server"   />
                                                                    
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtLiftingNetQuantity" runat="server"   />
                                                                    

                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="OgisUnitOfMeasure" HeaderText="UOM" />
                                                        </Columns>
                                                    </cc1:OgisGridView>



namespace OGIS.WebSite.Controls.Exportation
{
    public partial class BillOfLadingAddEditUc : BaseUserControl
    {
        private static int _billOfLadingId;
        private static int _liftingId;
        private static int _systemElectronicDocumentId;
        private static int _mode;
        private OGIS.Entity.BillOfLading _billOfLadingData;
        public static int _oilUnitOfMeasureId;
        public static int _gasUnitOfMeasureId;
        public static CultureInfo lang;
        public static string rowSelected;
        public static List<ExportLicenseGridRow> exportLicences = null;
        public static string hasLicence = "0";
        protected string ExportlicenceNotExistsMsg = string.Empty;
        //public string sessionTimeoutMsg;
        private ScannedDocumentBl bolDocBAL = null;
        private bool isBlendedProduct = false;
        public static List<ExportLicenseGridRow> selectedLicenses = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            CultureInfo lang = Thread.CurrentThread.CurrentCulture;
            hdnCulture.Value = lang.Name.ToLower() == "pt-pt" ? "pt-pt" : string.Empty;
            //sessionTimeoutMsg = BasePage.GetResString(Constants.SessionTimeoutMessage);
            btnCancel.OnClientClick = "javascript:self.parent.tb_remove();return false;";
            if(!IsPostBack)
            {                
                _billOfLadingData = new BillOfLading();
                lang = Thread.CurrentThread.CurrentCulture;       
                exportLicences = new List<ExportLicenseGridRow>();
            }

            if (Request["rowIndex"] != null)
            {
                if (Request["rowIndex"] != "")
                {
                    rowSelected = Request["rowIndex"].ToString();
                }
            }

            if (Request["billofladingid"]!=null)
            {
                if (Request["billofladingid"]!="")
                {
                    _billOfLadingId = Convert.ToInt32(Request["billofladingid"]);
                }
            }

            if (_billOfLadingId == 0)
            {
                _mode = 0; //create
                btnDelete.Visible = false;
            }
            else
            {
                _mode = 1; //edit
                btnDelete.Visible = true;
            }
            //isBlendedProduct = IsBlendedProduct(_liftingId); 
            if (_billOfLadingId > 0)
            {
                bolDocBAL = new ScannedDocumentBl();
                btnCreate.OnClientClick = ("javascript:ShowBillOfLadingDocument('DocumentScanner.aspx?BillOfLadingId=" + _billOfLadingId + "&documentTypeCategoryCode=" + bolDocBAL.GetDocumentTypeCategoryId(OgisConfiguration.DocumentType, OgisConfiguration.BillOfLadingDocCategoryCode) + "');return false;");
                lblAssociatedDocuments.Text = BasePage.GetResString(OGIS.Utility.BillOfLading.AssociatedDocuments);
                BindGridData();
            }
            else
            {
                btnCreate.Visible = false;
                gridAssocDocs.Visible = false;
                lblAssociatedDocuments.Visible = false;
                lblDocumentsResultsText.Visible = false;
            }
        }

        

        protected override void SetControlsLocaleStrings()
        {
                      
                LoadData();
           
        }

        protected override void LoadPageControls()
        {
            //LoadData();
            
           
                
        }

        public void GetExportLicence(int organisationUnitId, int oilAndGasProductId,int liftingId)
        {
            var objData = new ExportLicenceBillofLading();
            exportLicences = new List<ExportLicenseGridRow>();
            

                //var Grid = objData.GetExportLicence(systemisedElectronicFolderId);
                var Grid = objData.GetExportLicenceByExporter(organisationUnitId, oilAndGasProductId, liftingId);
                double LicenceTotal = 0.0;
                double OutStandingLicenceTotal = 0.0;

                foreach (var row in Grid)
                {
                    LicenceTotal = LicenceTotal + row.LicensedQuantity;

                }

                if (Grid != null)
                {
                    exportLicences = Grid;
                    ExporterGrid.DataSource = Grid;
                    
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                }

                ExporterGrid.DataBind();
                hdnGridCount.Value = exportLicences.Count.ToString();
                txtLicenceTotal.Text = LicenceTotal.ToString();

                OutStandingLicenceTotal = GetExportLicenceUsage(organisationUnitId, oilAndGasProductId, liftingId);

                //if (_billOfLadingData.ExportLicenses.Count >0)
                //{
                //    foreach (var row in _billOfLadingData.ExportLicenses)
                //    {
                //        OutStandingLicenceTotal = OutStandingLicenceTotal + row.LicensedQuantity;//.ExportLicenseAllocatedQuantity;
                //    }

                //}

                //txtOutstandingLicenseQuantity.Text = (LicenceTotal - OutStandingLicenceTotal).ToString();
                txtOutstandingLicenseQuantity.Text = (OutStandingLicenceTotal).ToString();

                if (LicenceTotal > 0)
                    GetLicences = "1";
                else
                    GetLicences = "0";
            
        }

        public double GetExportLicenceUsage(int exporterId, int oilGasProductId, int liftingId)
        {
            double retValue = 0;
            var objData = new ExportLicenceBillofLading();
            retValue = objData.GetOutstandingLicenceQtyOnLiftingDate(exporterId, oilGasProductId, liftingId);
            return retValue;
        }

       

       
        public void LoadData()
        {
            List<CustomsDeclaration> bolDeclarations = null;
            List<CustomsDeclaration> unAllocatedInitDeclarations = null;
            CustomsDeclaration initialDeclaration = null;
            CustomsDeclaration finalDeclaration = null;
            //List<CustomsDeclaration> initialDeclarations = null;
            CultureInfo lang = Thread.CurrentThread.CurrentCulture;
            string strSelect = "-- select --";
            var objData = new ExportLicenceBillofLading();
            isBlendedProduct = IsBlendedProduct(_liftingId); 
            _billOfLadingData = objData.GetBillOfLadingById(_billOfLadingId, _oilUnitOfMeasureId, _gasUnitOfMeasureId,_liftingId);

            if (_billOfLadingId > 0)
            {
                //_billOfLadingData = objData.GetBillOfLadingById(_billOfLadingId, _oilUnitOfMeasureId, _gasUnitOfMeasureId);
            }
            else
            {
                GetLicences = "0";
            }

            if (lang.Name == "pt-PT")
            {
                strSelect = "-- seleccione --";
            }

            bolDeclarations = objData.GetCustomsDeclarations(_billOfLadingId, _liftingId);
            if (bolDeclarations.Count > 0)
            {
                ddlAssociatedDeclaration.Items.Clear();  
                initialDeclaration = bolDeclarations.Where(du23 => du23.BillofLadingId == _billOfLadingId && du23.RegimeCode == "23" && du23.IsDeleted == false).FirstOrDefault();
                finalDeclaration = bolDeclarations.Where(du23 => du23.BillofLadingId == _billOfLadingId && du23.RegimeCode == "21" && du23.IsDeleted == false).FirstOrDefault();
                if (initialDeclaration != null)
                    ddlAssociatedDeclaration.Items.Add(new ListItem(initialDeclaration.DuNumber, initialDeclaration.CustomsDeclarationId.ToString()));
                else
                {
                    unAllocatedInitDeclarations = bolDeclarations.Where(du23 => du23.BillofLadingId == -1 && du23.RegimeCode == "23" && du23.IsDeleted == false).ToList();
                    Utility.WebHelper.FillDropDownList(ddlAssociatedDeclaration, unAllocatedInitDeclarations, "DuNumber", "CustomsDeclarationId", "-1", DropDownListName.None);
                }
                if (finalDeclaration != null)
                    txtFinalDeclarartion.Text = finalDeclaration.DuNumber;
            }
            else
                ddlAssociatedDeclaration.Items.Add(new ListItem(strSelect, "-1"));

            //if(ddlExporter!=null)
            //    ddlExporter.Items.Clear();
            //if (!Page.IsPostBack)
            //{
                //ddlExporter.DataSource = objData.GetExporters();
                //ddlExporter.DataTextField = "ExporterName";
                //ddlExporter.DataValueField = "ExporterId";
                //ddlExporter.DataBind();
                //ddlExporter.Items.Insert(0, new ListItem(strSelect, "-1"));
            //}

                WebHelper.FillDropDownList(ddlExporter, objData.GetExporters(), "ExporterName",
                               "ExporterId", Constants.Select,
                               DropDownListName.None);
            if (isBlendedProduct == true)
            {
                Utility.WebHelper.FillDropDownList(ddlProduct, objData.GetProductsForBlending(_liftingId), "OilGasProductName", "OilGasProductId", _billOfLadingData.OilGasProductId.HasValue ? _billOfLadingData.OilGasProductId.Value.ToString() : "-1", DropDownListName.None);
                ddlProduct.Enabled = true;
            }
            else
            {
                var liftingProduct = objData.GetLiftingProduct(_liftingId);
                ddlProduct.Items.Clear(); 
                ddlProduct.Items.Add(new ListItem(liftingProduct.OilGasProductName, liftingProduct.OilGasProductId.ToString()));    
                //Utility.WebHelper.FillDropDownList(ddlProduct, liftingProduct, "OilGasProductName", "OilGasProductId", liftingProduct.OilGasProductId.ToString(), DropDownListName.None);
                ddlProduct.Enabled = false;
            }

            if (_billOfLadingData!=null)
            {
                if (_billOfLadingData.ExporterOrganisationalUnitId > 0)
                {
                    ddlExporter.Items.FindByValue(_billOfLadingData.ExporterOrganisationalUnitId.ToString()).Selected = true;
                }
                if ((_billOfLadingData.ExporterOrganisationalUnitId > 0) && (ddlProduct.SelectedValue != "-1"))
                    //GetExportLicence(_billOfLadingData.ExporterOrganisationalUnitId, _billOfLadingData.OilGasProductId.Value, _billOfLadingData.LiftingId);
                    GetExportLicence(_billOfLadingData.ExporterOrganisationalUnitId, Convert.ToInt32(ddlProduct.SelectedValue), _billOfLadingData.LiftingId);
                else
                {
                    if (!Page.IsPostBack)
                    {
                        exportLicences = new List<ExportLicenseGridRow>();
                        ExporterGrid.DataSource = exportLicences;
                        ExporterGrid.DataBind();
                        hdnGridCount.Value = exportLicences.Count.ToString();
                    }
                }

                //UnselectOptions(ddlExporter);
                if (_billOfLadingData.ExporterOrganisationalUnitId > 0)
                    ddlExporter.Items.FindByValue(_billOfLadingData.ExporterOrganisationalUnitId.ToString()).Selected = true;

                UnselectOptions(ddlDestination);
                if (_billOfLadingData.DestinationCountryId > 0)
                    ddlDestination.Items.FindByValue(_billOfLadingData.DestinationCountryId.ToString()).Selected = true;
            }
            if (_billOfLadingData.LiftingId >0)
            {
                txtOperator.Text = _billOfLadingData.OperatorName;
                chkExportLicence.Checked = _billOfLadingData.OperatorExporter;
            }
            if (_billOfLadingId > 0)
            {
                txtBillOfLadingNo.Text = _billOfLadingData.BillOfLadingNumber;
                txtConfirmBillNumber.Text = _billOfLadingData.BillOfLadingNumber;
                //txtOperator.Text = _billOfLadingData.OperatorName;
                //chkExportLicence.Checked = _billOfLadingData.OperatorExporter;
                txtQualityFrom.Text = _billOfLadingData.QualityFrom.ToString();
                txtQualityTo.Text = _billOfLadingData.QualityTo.ToString();

                if (_liftingId > 0)
                    txtUOM1.Text = objData.GetUoM(_liftingId, _billOfLadingId, 1);

                txtGrossQty.Text = _billOfLadingData.GrossQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM2.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);

                txtNetQty.Text = _billOfLadingData.NetQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM3.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);

                txtExportLicenseQuota1.Text = txtUOM2.Text;
                txtExportLicenseQuota2.Text = txtUOM2.Text;
            }
            else
            {
                if (_liftingId > 0)
                    txtUOM1.Text = objData.GetUoM(_liftingId, 0, 1);

                txtGrossQty.Text = _billOfLadingData.GrossQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM2.Text = objData.GetUoM(_liftingId, 0, 2);

                if (_liftingId > 0)
                    txtUOM3.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);
            }

            objData = null;
             //ExportLicenceWorning(); 


        }

        
        
        public void UnselectOptions(DropDownList objDrop)
        {
            for(int i = 0; i<objDrop.Items.Count;i++)
            {
                objDrop.Items[i].Selected = false;
            }
        }

       

        
        protected void ExporterGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[1].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.ExportLicenceNo);
                grv.Cells[2].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssueDate);
                grv.Cells[3].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.ExpiryDate);
                grv.Cells[4].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.LicenceQuantity);
                grv.Cells[5].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.GrossQuantity);
                grv.Cells[6].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.NetQuantity);
                grv.Cells[7].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Uom);
            }
        }
       

        protected void ExporterGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (OGIS.Entity.ExportLicenseGridRow)e.Row.DataItem;

            if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowType != DataControlRowType.Header)
            {
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");
                e.Row.Cells[2].Text = Convert.ToDateTime(e.Row.Cells[2].Text).ToFormatedDate();
                e.Row.Cells[3].Text = Convert.ToDateTime(e.Row.Cells[3].Text).ToFormatedDate();
            }
        }

        protected void DocumentAssociatedGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[0].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Type);
                grv.Cells[1].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Id);
                grv.Cells[2].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssueDate);
                grv.Cells[3].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssuingOrganisationType);
                grv.Cells[4].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssuingOrganisation);
            }
        }

        protected void DocumentAssociatedGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (OGIS.Entity.OilAndGasCompany)e.Row.DataItem;

            if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowType != DataControlRowType.Header)
            {
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");

            }

        }

        protected void btnRefreshGrid_Click(object sender, EventArgs e)
        {
            BindGridData();
        }

        protected void gridAssocDocs_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[0].Text = BasePage.GetResString(LocDeclaration.AssociatedDocType);
                grv.Cells[1].Text = BasePage.GetResString(LocDeclaration.AssociatedDocId);
                grv.Cells[2].Text = BasePage.GetResString(LocDeclaration.AssociatedDocIssueDate);
                grv.Cells[3].Text = BasePage.GetResString(LocDeclaration.IssuingOrgType);
                grv.Cells[4].Text = BasePage.GetResString(LocDeclaration.IssuingOrg);
            }
        }

        protected void gridAssocDocs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (SystemisedEletronicDocumentGrid)e.Row.DataItem;
            var grv = (GridViewRow)e.Row;
            if ((e.Row.RowType == DataControlRowType.DataRow) && (e.Row.RowType != DataControlRowType.Header))
            {
                //e.Row.Attributes.Add("onclick", "ShowCustomsDeclarationDocument('CustomsDeclarationDocViewer.aspx?DocumentId=" + gridAssocDocs.DataKeys[e.Row.RowIndex].Value.ToString() + "','dialogHeight:" + _popupHeight.ToString() + "px;dialogWidth:" + _popupWidth.ToString() + ";center:yes;status:no;toolbar:no;location:no;');");
                e.Row.Attributes.Add("onclick", "ShowBillOfLadingDocument('CustomsDeclarationDocViewer.aspx?DocumentId=" + gridAssocDocs.DataKeys[e.Row.RowIndex].Value.ToString() + "');return false;");
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");
                if (drv.SystemisedEletronicDocumentId == 0)
                    e.Row.Visible = false;
            }
        }

        public void BindGridData()
        {
            int totalCount = 0;
            bolDocBAL = new ScannedDocumentBl();
            OGIS.Entity.OgisCustomCollections<OGIS.Entity.SystemisedEletronicDocumentGrid> bolDocs = bolDocBAL.GetBillOfLadingDocuments(_billOfLadingId, Convert.ToInt32(UserAuthentication.Instance.OganisationId), out totalCount);
            if (bolDocs != null)
            {
                gridAssocDocs.DataSource = bolDocs;
                gridAssocDocs.DataBind();
                lblDocumentsResultsText.Text = totalCount > 1 ? totalCount.ToString() + " " + BasePage.GetResString(LocDeclaration.DeclarationDocumentsResultsPluralText) + " " + BasePage.GetResString(GlobalLocStrings.FoundText2) : totalCount.ToString() + " " + BasePage.GetResString(LocDeclaration.DeclarationDocumentsResultsText) + " " + BasePage.GetResString(GlobalLocStrings.FoundText2);
            }
        }

        protected void ddlProduct_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlProduct.SelectedValue != "-1")
            {
                int exporterId = Convert.ToInt32(ddlExporter.SelectedItem.Value);
                txtLicenceTotal.Text = "";
                txtOutstandingLicenseQuantity.Text = "";

                if (_billOfLadingData != null)
                {
                    _billOfLadingData.ExportLicenses = new List<ExportLicenseGridRow>();
                }

                int oilAndGasProductId = 0;
                if (exporterId > -1)
                {
                    //if (isBlendedProduct)
                        oilAndGasProductId = Convert.ToInt32(ddlProduct.SelectedValue);
                    //else
                        //oilAndGasProductId = getOilGasProductByLiftingId(_liftingId);
                    GetExportLicence(exporterId, oilAndGasProductId, _liftingId);
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                    ExporterGrid.DataBind();
                    hdnGridCount.Value = exportLicences.Count.ToString();
                }
                SetClientSideVariable();
            }
        }

       

        public bool ValidateDouble(string dValue)
        {
            double  newValue = 0; 
            try
            {
                newValue = Convert.ToDouble(dValue);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        protected void GetExporterLicences_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (GridViewRow row in ExporterGrid.Rows)
            {
                var chkExportLicense = (CheckBox)row.Cells[0].FindControl("chkExportLicense");
                if (chkExportLicense != null)
                {
                    if (chkExportLicense.Checked)
                    {
                        selectedLicenses.Add(new ExportLicenseGridRow()
                        {
                            ExportLicenseId = Convert.ToInt32(ExporterGrid.DataKeys[row.RowIndex].Value),
                            BolGrossQuantity = Convert.ToDouble(((TextBox)row.FindControl("txtLiftingGrossQuantity")).Text),
                            BolNetQuantity = Convert.ToDouble(((TextBox)row.FindControl("txtLiftingGrossQuantity")).Text)
                        }
                        );

                    }
                }
            }
            hasLicence = "0";
            if (ddlProduct.SelectedValue != "-1")
            {
                int exporterId = Convert.ToInt32(ddlExporter.SelectedItem.Value);
                txtLicenceTotal.Text = "";
                txtOutstandingLicenseQuantity.Text = "";

                if (_billOfLadingData != null)
                {
                    _billOfLadingData.ExportLicenses = new List<ExportLicenseGridRow>();
                }

                int oilAndGasProductId = 0;
                if (exporterId > -1)
                {
                    //if (isBlendedProduct)
                    oilAndGasProductId = Convert.ToInt32(ddlProduct.SelectedValue);
                    //else
                    //oilAndGasProductId = getOilGasProductByLiftingId(_liftingId);
                    GetExportLicence(exporterId, oilAndGasProductId, _liftingId);
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                    ExporterGrid.DataBind();
                    hdnGridCount.Value = exportLicences.Count.ToString();
                }
                SetClientSideVariable();
            }
        }


    }
}
ASP.NET C# Dropdown selected index firing on button click
===

Problem description:

See the screen attached.The exporter dropdown selected index changed is fired on button save click for some reason.Another strange thing happening is that the textbox & checkbox value inside gridview are lost which I guess is because gridview is populated everytime the selected index is changed.Please advise....

Problem is I am not able to capture the checbox and texbox values at any point...
Goal is to save the textbox values inside in the database but the checkbox and textbox are always false and blank respectively.




HTML 
Exporter ddl

<asp:DropDownList ID="ddlExporter" runat="server" AutoPostBack="true" OnSelectedIndexChanged="GetExporterLicences_OnSelectedIndexChanged" InitialValue="-1" >
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator ID="rqExporter" ControlToValidate="ddlExporter" ValidationGroup="bolDetails"
                                                        InitialValue="-1" SetFocusOnError="true" Text="*" runat="server"></asp:RequiredFieldValidator>



Gridview

  <cc1:OgisGridView ID="ExporterGrid" runat="server" CssClass="mGrid" AutoGenerateColumns="false"
                                                        Width="100%" DataKeyNames="ExportLicenseId" OnRowCreated="ExporterGrid_RowCreated" 
                                                        OnRowDataBound="ExporterGrid_RowDataBound">
                                                        <HeaderStyle CssClass="gridHeader" />
                                                        <RowStyle CssClass="gridRow" HorizontalAlign="Left"  />
                                                        <AlternatingRowStyle CssClass="gridAlternative" />
                                                        <Columns>
                                                        <asp:TemplateField>
                                                        

                                                                 <ItemTemplate>
                                                                    <asp:CheckBox ID="chkExportLicense" runat="server"  />
                                                                </ItemTemplate>
                                                            </asp:TemplateField>

                                                            <asp:BoundField DataField="ExportLicenseNumber" HeaderText="Export licence no." ItemStyle-HorizontalAlign="Right" />
                                                            <asp:BoundField DataField="IssueDate" HeaderText="Issue date" ItemStyle-HorizontalAlign="Center" />
                                                            <asp:BoundField DataField="ExpireDate" HeaderText="Expiry date" ItemStyle-HorizontalAlign="Center" />
                                                            <asp:BoundField DataField="LicensedQuantity" HeaderText="Licence quantity" ItemStyle-HorizontalAlign="Right" />
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtLiftingGrossQuantity" runat="server"   />
                                                                    
                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtLiftingNetQuantity" runat="server"   />
                                                                    

                                                                </ItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="OgisUnitOfMeasure" HeaderText="UOM" />
                                                        </Columns>
                                                    </cc1:OgisGridView>



namespace OGIS.WebSite.Controls.Exportation
{
    public partial class BillOfLadingAddEditUc : BaseUserControl
    {
        private static int _billOfLadingId;
        private static int _liftingId;
        private static int _systemElectronicDocumentId;
        private static int _mode;
        private OGIS.Entity.BillOfLading _billOfLadingData;
        public static int _oilUnitOfMeasureId;
        public static int _gasUnitOfMeasureId;
        public static CultureInfo lang;
        public static string rowSelected;
        public static List<ExportLicenseGridRow> exportLicences = null;
        public static string hasLicence = "0";
        protected string ExportlicenceNotExistsMsg = string.Empty;
        //public string sessionTimeoutMsg;
        private ScannedDocumentBl bolDocBAL = null;
        private bool isBlendedProduct = false;
        public static List<ExportLicenseGridRow> selectedLicenses = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            CultureInfo lang = Thread.CurrentThread.CurrentCulture;
            hdnCulture.Value = lang.Name.ToLower() == "pt-pt" ? "pt-pt" : string.Empty;
            //sessionTimeoutMsg = BasePage.GetResString(Constants.SessionTimeoutMessage);
            btnCancel.OnClientClick = "javascript:self.parent.tb_remove();return false;";
            if(!IsPostBack)
            {                
                _billOfLadingData = new BillOfLading();
                lang = Thread.CurrentThread.CurrentCulture;       
                exportLicences = new List<ExportLicenseGridRow>();
            }

            if (Request["rowIndex"] != null)
            {
                if (Request["rowIndex"] != "")
                {
                    rowSelected = Request["rowIndex"].ToString();
                }
            }

            if (Request["billofladingid"]!=null)
            {
                if (Request["billofladingid"]!="")
                {
                    _billOfLadingId = Convert.ToInt32(Request["billofladingid"]);
                }
            }

            if (_billOfLadingId == 0)
            {
                _mode = 0; //create
                btnDelete.Visible = false;
            }
            else
            {
                _mode = 1; //edit
                btnDelete.Visible = true;
            }
            //isBlendedProduct = IsBlendedProduct(_liftingId); 
            if (_billOfLadingId > 0)
            {
                bolDocBAL = new ScannedDocumentBl();
                btnCreate.OnClientClick = ("javascript:ShowBillOfLadingDocument('DocumentScanner.aspx?BillOfLadingId=" + _billOfLadingId + "&documentTypeCategoryCode=" + bolDocBAL.GetDocumentTypeCategoryId(OgisConfiguration.DocumentType, OgisConfiguration.BillOfLadingDocCategoryCode) + "');return false;");
                lblAssociatedDocuments.Text = BasePage.GetResString(OGIS.Utility.BillOfLading.AssociatedDocuments);
                BindGridData();
            }
            else
            {
                btnCreate.Visible = false;
                gridAssocDocs.Visible = false;
                lblAssociatedDocuments.Visible = false;
                lblDocumentsResultsText.Visible = false;
            }
        }

        

        protected override void SetControlsLocaleStrings()
        {
                      
                LoadData();
           
        }

        protected override void LoadPageControls()
        {
            //LoadData();
            
           
                
        }

        public void GetExportLicence(int organisationUnitId, int oilAndGasProductId,int liftingId)
        {
            var objData = new ExportLicenceBillofLading();
            exportLicences = new List<ExportLicenseGridRow>();
            

                //var Grid = objData.GetExportLicence(systemisedElectronicFolderId);
                var Grid = objData.GetExportLicenceByExporter(organisationUnitId, oilAndGasProductId, liftingId);
                double LicenceTotal = 0.0;
                double OutStandingLicenceTotal = 0.0;

                foreach (var row in Grid)
                {
                    LicenceTotal = LicenceTotal + row.LicensedQuantity;

                }

                if (Grid != null)
                {
                    exportLicences = Grid;
                    ExporterGrid.DataSource = Grid;
                    
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                }

                ExporterGrid.DataBind();
                hdnGridCount.Value = exportLicences.Count.ToString();
                txtLicenceTotal.Text = LicenceTotal.ToString();

                OutStandingLicenceTotal = GetExportLicenceUsage(organisationUnitId, oilAndGasProductId, liftingId);

                //if (_billOfLadingData.ExportLicenses.Count >0)
                //{
                //    foreach (var row in _billOfLadingData.ExportLicenses)
                //    {
                //        OutStandingLicenceTotal = OutStandingLicenceTotal + row.LicensedQuantity;//.ExportLicenseAllocatedQuantity;
                //    }

                //}

                //txtOutstandingLicenseQuantity.Text = (LicenceTotal - OutStandingLicenceTotal).ToString();
                txtOutstandingLicenseQuantity.Text = (OutStandingLicenceTotal).ToString();

                if (LicenceTotal > 0)
                    GetLicences = "1";
                else
                    GetLicences = "0";
            
        }

        public double GetExportLicenceUsage(int exporterId, int oilGasProductId, int liftingId)
        {
            double retValue = 0;
            var objData = new ExportLicenceBillofLading();
            retValue = objData.GetOutstandingLicenceQtyOnLiftingDate(exporterId, oilGasProductId, liftingId);
            return retValue;
        }

       

       
        public void LoadData()
        {
            List<CustomsDeclaration> bolDeclarations = null;
            List<CustomsDeclaration> unAllocatedInitDeclarations = null;
            CustomsDeclaration initialDeclaration = null;
            CustomsDeclaration finalDeclaration = null;
            //List<CustomsDeclaration> initialDeclarations = null;
            CultureInfo lang = Thread.CurrentThread.CurrentCulture;
            string strSelect = "-- select --";
            var objData = new ExportLicenceBillofLading();
            isBlendedProduct = IsBlendedProduct(_liftingId); 
            _billOfLadingData = objData.GetBillOfLadingById(_billOfLadingId, _oilUnitOfMeasureId, _gasUnitOfMeasureId,_liftingId);

            if (_billOfLadingId > 0)
            {
                //_billOfLadingData = objData.GetBillOfLadingById(_billOfLadingId, _oilUnitOfMeasureId, _gasUnitOfMeasureId);
            }
            else
            {
                GetLicences = "0";
            }

            if (lang.Name == "pt-PT")
            {
                strSelect = "-- seleccione --";
            }

            bolDeclarations = objData.GetCustomsDeclarations(_billOfLadingId, _liftingId);
            if (bolDeclarations.Count > 0)
            {
                ddlAssociatedDeclaration.Items.Clear();  
                initialDeclaration = bolDeclarations.Where(du23 => du23.BillofLadingId == _billOfLadingId && du23.RegimeCode == "23" && du23.IsDeleted == false).FirstOrDefault();
                finalDeclaration = bolDeclarations.Where(du23 => du23.BillofLadingId == _billOfLadingId && du23.RegimeCode == "21" && du23.IsDeleted == false).FirstOrDefault();
                if (initialDeclaration != null)
                    ddlAssociatedDeclaration.Items.Add(new ListItem(initialDeclaration.DuNumber, initialDeclaration.CustomsDeclarationId.ToString()));
                else
                {
                    unAllocatedInitDeclarations = bolDeclarations.Where(du23 => du23.BillofLadingId == -1 && du23.RegimeCode == "23" && du23.IsDeleted == false).ToList();
                    Utility.WebHelper.FillDropDownList(ddlAssociatedDeclaration, unAllocatedInitDeclarations, "DuNumber", "CustomsDeclarationId", "-1", DropDownListName.None);
                }
                if (finalDeclaration != null)
                    txtFinalDeclarartion.Text = finalDeclaration.DuNumber;
            }
            else
                ddlAssociatedDeclaration.Items.Add(new ListItem(strSelect, "-1"));

            //if(ddlExporter!=null)
            //    ddlExporter.Items.Clear();
            //if (!Page.IsPostBack)
            //{
                //ddlExporter.DataSource = objData.GetExporters();
                //ddlExporter.DataTextField = "ExporterName";
                //ddlExporter.DataValueField = "ExporterId";
                //ddlExporter.DataBind();
                //ddlExporter.Items.Insert(0, new ListItem(strSelect, "-1"));
            //}

                WebHelper.FillDropDownList(ddlExporter, objData.GetExporters(), "ExporterName",
                               "ExporterId", Constants.Select,
                               DropDownListName.None);
            if (isBlendedProduct == true)
            {
                Utility.WebHelper.FillDropDownList(ddlProduct, objData.GetProductsForBlending(_liftingId), "OilGasProductName", "OilGasProductId", _billOfLadingData.OilGasProductId.HasValue ? _billOfLadingData.OilGasProductId.Value.ToString() : "-1", DropDownListName.None);
                ddlProduct.Enabled = true;
            }
            else
            {
                var liftingProduct = objData.GetLiftingProduct(_liftingId);
                ddlProduct.Items.Clear(); 
                ddlProduct.Items.Add(new ListItem(liftingProduct.OilGasProductName, liftingProduct.OilGasProductId.ToString()));    
                //Utility.WebHelper.FillDropDownList(ddlProduct, liftingProduct, "OilGasProductName", "OilGasProductId", liftingProduct.OilGasProductId.ToString(), DropDownListName.None);
                ddlProduct.Enabled = false;
            }

            if (_billOfLadingData!=null)
            {
                if (_billOfLadingData.ExporterOrganisationalUnitId > 0)
                {
                    ddlExporter.Items.FindByValue(_billOfLadingData.ExporterOrganisationalUnitId.ToString()).Selected = true;
                }
                if ((_billOfLadingData.ExporterOrganisationalUnitId > 0) && (ddlProduct.SelectedValue != "-1"))
                    //GetExportLicence(_billOfLadingData.ExporterOrganisationalUnitId, _billOfLadingData.OilGasProductId.Value, _billOfLadingData.LiftingId);
                    GetExportLicence(_billOfLadingData.ExporterOrganisationalUnitId, Convert.ToInt32(ddlProduct.SelectedValue), _billOfLadingData.LiftingId);
                else
                {
                    if (!Page.IsPostBack)
                    {
                        exportLicences = new List<ExportLicenseGridRow>();
                        ExporterGrid.DataSource = exportLicences;
                        ExporterGrid.DataBind();
                        hdnGridCount.Value = exportLicences.Count.ToString();
                    }
                }

                //UnselectOptions(ddlExporter);
                if (_billOfLadingData.ExporterOrganisationalUnitId > 0)
                    ddlExporter.Items.FindByValue(_billOfLadingData.ExporterOrganisationalUnitId.ToString()).Selected = true;

                UnselectOptions(ddlDestination);
                if (_billOfLadingData.DestinationCountryId > 0)
                    ddlDestination.Items.FindByValue(_billOfLadingData.DestinationCountryId.ToString()).Selected = true;
            }
            if (_billOfLadingData.LiftingId >0)
            {
                txtOperator.Text = _billOfLadingData.OperatorName;
                chkExportLicence.Checked = _billOfLadingData.OperatorExporter;
            }
            if (_billOfLadingId > 0)
            {
                txtBillOfLadingNo.Text = _billOfLadingData.BillOfLadingNumber;
                txtConfirmBillNumber.Text = _billOfLadingData.BillOfLadingNumber;
                //txtOperator.Text = _billOfLadingData.OperatorName;
                //chkExportLicence.Checked = _billOfLadingData.OperatorExporter;
                txtQualityFrom.Text = _billOfLadingData.QualityFrom.ToString();
                txtQualityTo.Text = _billOfLadingData.QualityTo.ToString();

                if (_liftingId > 0)
                    txtUOM1.Text = objData.GetUoM(_liftingId, _billOfLadingId, 1);

                txtGrossQty.Text = _billOfLadingData.GrossQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM2.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);

                txtNetQty.Text = _billOfLadingData.NetQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM3.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);

                txtExportLicenseQuota1.Text = txtUOM2.Text;
                txtExportLicenseQuota2.Text = txtUOM2.Text;
            }
            else
            {
                if (_liftingId > 0)
                    txtUOM1.Text = objData.GetUoM(_liftingId, 0, 1);

                txtGrossQty.Text = _billOfLadingData.GrossQuantity.ToString();

                if (_liftingId > 0)
                    txtUOM2.Text = objData.GetUoM(_liftingId, 0, 2);

                if (_liftingId > 0)
                    txtUOM3.Text = objData.GetUoM(_liftingId, _billOfLadingId, 2);
            }

            objData = null;
             //ExportLicenceWorning(); 


        }

        
        
        public void UnselectOptions(DropDownList objDrop)
        {
            for(int i = 0; i<objDrop.Items.Count;i++)
            {
                objDrop.Items[i].Selected = false;
            }
        }

       

        
        protected void ExporterGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[1].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.ExportLicenceNo);
                grv.Cells[2].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssueDate);
                grv.Cells[3].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.ExpiryDate);
                grv.Cells[4].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.LicenceQuantity);
                grv.Cells[5].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.GrossQuantity);
                grv.Cells[6].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.NetQuantity);
                grv.Cells[7].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Uom);
            }
        }
       

        protected void ExporterGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (OGIS.Entity.ExportLicenseGridRow)e.Row.DataItem;

            if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowType != DataControlRowType.Header)
            {
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");
                e.Row.Cells[2].Text = Convert.ToDateTime(e.Row.Cells[2].Text).ToFormatedDate();
                e.Row.Cells[3].Text = Convert.ToDateTime(e.Row.Cells[3].Text).ToFormatedDate();
            }
        }

        protected void DocumentAssociatedGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[0].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Type);
                grv.Cells[1].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.Id);
                grv.Cells[2].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssueDate);
                grv.Cells[3].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssuingOrganisationType);
                grv.Cells[4].Text = BasePage.GetResString(OGIS.Utility.BillOfLading.IssuingOrganisation);
            }
        }

        protected void DocumentAssociatedGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (OGIS.Entity.OilAndGasCompany)e.Row.DataItem;

            if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowType != DataControlRowType.Header)
            {
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");

            }

        }

        protected void btnRefreshGrid_Click(object sender, EventArgs e)
        {
            BindGridData();
        }

        protected void gridAssocDocs_RowCreated(object sender, GridViewRowEventArgs e)
        {
            var grv = (GridViewRow)e.Row;
            if (e.Row.RowType == DataControlRowType.Header)
            {
                grv.Cells[0].Text = BasePage.GetResString(LocDeclaration.AssociatedDocType);
                grv.Cells[1].Text = BasePage.GetResString(LocDeclaration.AssociatedDocId);
                grv.Cells[2].Text = BasePage.GetResString(LocDeclaration.AssociatedDocIssueDate);
                grv.Cells[3].Text = BasePage.GetResString(LocDeclaration.IssuingOrgType);
                grv.Cells[4].Text = BasePage.GetResString(LocDeclaration.IssuingOrg);
            }
        }

        protected void gridAssocDocs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var drv = (SystemisedEletronicDocumentGrid)e.Row.DataItem;
            var grv = (GridViewRow)e.Row;
            if ((e.Row.RowType == DataControlRowType.DataRow) && (e.Row.RowType != DataControlRowType.Header))
            {
                //e.Row.Attributes.Add("onclick", "ShowCustomsDeclarationDocument('CustomsDeclarationDocViewer.aspx?DocumentId=" + gridAssocDocs.DataKeys[e.Row.RowIndex].Value.ToString() + "','dialogHeight:" + _popupHeight.ToString() + "px;dialogWidth:" + _popupWidth.ToString() + ";center:yes;status:no;toolbar:no;location:no;');");
                e.Row.Attributes.Add("onclick", "ShowBillOfLadingDocument('CustomsDeclarationDocViewer.aspx?DocumentId=" + gridAssocDocs.DataKeys[e.Row.RowIndex].Value.ToString() + "');return false;");
                if (e.Row.RowState == DataControlRowState.Alternate)
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridAlternative';");
                }
                else
                {
                    e.Row.Attributes.Add("onmouseout", "this.className='gridRow';");
                }
                e.Row.Attributes.Add("onmouseover", "this.className='gridHover';");
                if (drv.SystemisedEletronicDocumentId == 0)
                    e.Row.Visible = false;
            }
        }

        public void BindGridData()
        {
            int totalCount = 0;
            bolDocBAL = new ScannedDocumentBl();
            OGIS.Entity.OgisCustomCollections<OGIS.Entity.SystemisedEletronicDocumentGrid> bolDocs = bolDocBAL.GetBillOfLadingDocuments(_billOfLadingId, Convert.ToInt32(UserAuthentication.Instance.OganisationId), out totalCount);
            if (bolDocs != null)
            {
                gridAssocDocs.DataSource = bolDocs;
                gridAssocDocs.DataBind();
                lblDocumentsResultsText.Text = totalCount > 1 ? totalCount.ToString() + " " + BasePage.GetResString(LocDeclaration.DeclarationDocumentsResultsPluralText) + " " + BasePage.GetResString(GlobalLocStrings.FoundText2) : totalCount.ToString() + " " + BasePage.GetResString(LocDeclaration.DeclarationDocumentsResultsText) + " " + BasePage.GetResString(GlobalLocStrings.FoundText2);
            }
        }

        protected void ddlProduct_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlProduct.SelectedValue != "-1")
            {
                int exporterId = Convert.ToInt32(ddlExporter.SelectedItem.Value);
                txtLicenceTotal.Text = "";
                txtOutstandingLicenseQuantity.Text = "";

                if (_billOfLadingData != null)
                {
                    _billOfLadingData.ExportLicenses = new List<ExportLicenseGridRow>();
                }

                int oilAndGasProductId = 0;
                if (exporterId > -1)
                {
                    //if (isBlendedProduct)
                        oilAndGasProductId = Convert.ToInt32(ddlProduct.SelectedValue);
                    //else
                        //oilAndGasProductId = getOilGasProductByLiftingId(_liftingId);
                    GetExportLicence(exporterId, oilAndGasProductId, _liftingId);
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                    ExporterGrid.DataBind();
                    hdnGridCount.Value = exportLicences.Count.ToString();
                }
                SetClientSideVariable();
            }
        }

       

        public bool ValidateDouble(string dValue)
        {
            double  newValue = 0; 
            try
            {
                newValue = Convert.ToDouble(dValue);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        protected void GetExporterLicences_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (GridViewRow row in ExporterGrid.Rows)
            {
                var chkExportLicense = (CheckBox)row.Cells[0].FindControl("chkExportLicense");
                if (chkExportLicense != null)
                {
                    if (chkExportLicense.Checked)
                    {
                        selectedLicenses.Add(new ExportLicenseGridRow()
                        {
                            ExportLicenseId = Convert.ToInt32(ExporterGrid.DataKeys[row.RowIndex].Value),
                            BolGrossQuantity = Convert.ToDouble(((TextBox)row.FindControl("txtLiftingGrossQuantity")).Text),
                            BolNetQuantity = Convert.ToDouble(((TextBox)row.FindControl("txtLiftingGrossQuantity")).Text)
                        }
                        );

                    }
                }
            }
            hasLicence = "0";
            if (ddlProduct.SelectedValue != "-1")
            {
                int exporterId = Convert.ToInt32(ddlExporter.SelectedItem.Value);
                txtLicenceTotal.Text = "";
                txtOutstandingLicenseQuantity.Text = "";

                if (_billOfLadingData != null)
                {
                    _billOfLadingData.ExportLicenses = new List<ExportLicenseGridRow>();
                }

                int oilAndGasProductId = 0;
                if (exporterId > -1)
                {
                    //if (isBlendedProduct)
                    oilAndGasProductId = Convert.ToInt32(ddlProduct.SelectedValue);
                    //else
                    //oilAndGasProductId = getOilGasProductByLiftingId(_liftingId);
                    GetExportLicence(exporterId, oilAndGasProductId, _liftingId);
                }
                else
                {
                    ExporterGrid.DataSource = new List<ExportLicenseGridRow>();
                    ExporterGrid.DataBind();
                    hdnGridCount.Value = exportLicences.Count.ToString();
                }
                SetClientSideVariable();
            }
        }


    }
}