protected void btnsave_Click(object sender, EventArgs e)
    {
        try
        {
            BranchMaster _objbranch = new BranchMaster();
            _objbranch.BranchID      = Convert.ToInt32(lblBranchId.Text);
            _objbranch.BranchCode    = txtbranchCode.Text.Trim();
            _objbranch.BranchName    = txtbranchName.Text.Trim();
            _objbranch.BranchAddress = txtbranchAddress.Text.Trim();
            //_obranchnk.Country = txtcountry.Text.Trim();
            _objbranch.State     = Convert.ToInt32(DDLstate.SelectedValue);
            _objbranch.City      = Convert.ToInt32(DDLCity.SelectedValue);
            _objbranch.IsActive  = chekactive.Checked;
            _objbranch.IsDelete  = false;
            _objbranch.CreatedBy = "Admin";
            _objbranch.Remark1   = "";
            _objbranch.Remark2   = "";
            _objbranch.Remark3   = "";

            //Response.Write(_objbranch.BranchCode + "\n" + _objbranch.BranchName + "\n" + _objbranch.BranchAddress + "\n" + _objbranch.State + "\n" + _objbranch.City + "\n" + _objbranch.IsActive + "\n" + _objbranch.IsDelete + "\n");


            _objbranch.Save();

            MessageBox("Record saved successfully");
            BindGvBranchDetails();
            if (btnsave.Text.ToString() == "Update")
            {
                Panel1.Visible    = false;
                pnlBranch.Visible = true;
                filter.Visible    = true;
                btnsave.Visible   = false;
            }
            else
            {
                Panel1.Visible    = true;
                pnlBranch.Visible = false;
                filter.Visible    = false;
                btnsave.Visible   = true;
            }

            lblBranchId.Text   = "";
            txtbranchCode.Text = "";
            txtbranchName.Text = "";
            //txtcountry.Text = "";
            txtbranchAddress.Text  = "";
            chekactive.Checked     = false;
            DDLCity.SelectedValue  = null;
            DDLstate.SelectedValue = null;

            //UpdatePanel1.Update();
            //UpdatePanel2.Update();
            //UpdatePanel4.Update();
        }
        catch
        {
        }
    }
    protected void grdBranchDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BranchMaster _objBranch = new BranchMaster();

        _objBranch.BranchID      = Convert.ToInt32(((Label)grdBranchDetails.Rows[e.RowIndex].FindControl("lblBranchID")).Text);
        _objBranch.BranchName    = (((Label)grdBranchDetails.Rows[e.RowIndex].FindControl("lblBranchName")).Text);
        _objBranch.BranchAddress = (((Label)grdBranchDetails.Rows[e.RowIndex].FindControl("lblBranchAddress")).Text);
        _objBranch.IsActive      = Convert.ToBoolean(false);
        _objBranch.IsDelete      = Convert.ToBoolean(true);
        try
        {
            _objBranch.Save();
            BindGvBranchDetails();
            Panel1.Visible    = false;
            pnlBranch.Visible = true;
        }
        catch
        {
        }
    }