protected void SubmitButton_Click(object sender, EventArgs e)
    {
        da = new SqlDataAdapter("insert into Package_Details(P_Type,P_Category,Country,City,Days,Amount,Description)values('" + DropDownListType.SelectedItem.Text + "','" + DropdownCategory.SelectedItem.Text + "','" + DropDownCountry.SelectedItem.Text + "','" + DropDownCity.SelectedItem.Text + "','" + TextBoxDays.Text + "'," + TextBoxAmount.Text + ",'" + TextBoxDesc.Text + "')", con);
        dt = new DataTable();
        da.Fill(dt);
        Label1.Text = "Data Submit Successfully";
        DropDownCountry.ClearSelection();
        DropDownCity.ClearSelection();
        DropdownCategory.ClearSelection();
        DropDownListType.ClearSelection();
        TextBoxDays.Text   = "";
        TextBoxAmount.Text = "";
        TextBoxDesc.Text   = "";

        da = new SqlDataAdapter("select * from Package_Details order by P_Id desc", con);
        dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            GridViewPackageDetails.DataSource = dt;
            GridViewPackageDetails.DataBind();
        }
        else
        {
            GridViewPackageDetails.DataSource = "";
            GridViewPackageDetails.DataBind();
        }
    }
 protected void GridViewPackageDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridViewPackageDetails.PageIndex = e.NewPageIndex;
     da = new SqlDataAdapter("select * from Package_Details order by P_Id desc", con);
     dt = new DataTable();
     da.Fill(dt);
     if (dt.Rows.Count > 0)
     {
         GridViewPackageDetails.DataSource = dt;
         GridViewPackageDetails.DataBind();
     }
     else
     {
         GridViewPackageDetails.DataSource = "";
         GridViewPackageDetails.DataBind();
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(ConfigurationManager.AppSettings["con"]);

        if (Page.IsPostBack == false)
        {
            da = new SqlDataAdapter("select * from Package_Details order by P_Id desc", con);
            dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                GridViewPackageDetails.DataSource = dt;
                GridViewPackageDetails.DataBind();
            }
            else
            {
                GridViewPackageDetails.DataSource = "";
                GridViewPackageDetails.DataBind();
            }
        }
        if (Page.IsPostBack == false)
        {
            da = new SqlDataAdapter("select PackageCategory from  PackageCategory", con);
            dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                DropdownCategory.DataSource    = dt;
                DropdownCategory.DataTextField = "PackageCategory";
                DropdownCategory.DataBind();

                DropdownCategory.Items.Insert(0, "Select Package");
                DropdownCategory.Items.Insert(dt.Rows.Count + 1, "Other Package");
            }

            da = new SqlDataAdapter("select distinct CountryName from CountryCityMaster order by CountryName", con);
            dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                DropDownCountry.DataSource    = dt;
                DropDownCountry.DataTextField = "CountryName";
                DropDownCountry.DataBind();

                DropDownCountry.Items.Insert(0, "Select Country");
                DropDownCountry.Items.Insert(dt.Rows.Count + 1, "Other Country");
            }


            if (Request.QueryString["P"] == "AMP")
            {
                hiderow1.Visible               = true;
                hiderow2.Visible               = true;
                hiderow3.Visible               = true;
                SubmitButton1.Visible          = true;
                SearchButton.Visible           = false;
                titleLabel.Text                = "Insert Package Detail";
                GridViewPackageDetails.Visible = true;
            }
            else if (Request.QueryString["P"] == "UMP")
            {
                hiderow1.Visible               = false;
                hiderow2.Visible               = false;
                hiderow3.Visible               = false;
                SubmitButton1.Visible          = false;
                SearchButton.Visible           = true;
                titleLabel.Text                = "Search Package";
                GridViewPackageDetails.Visible = false;
            }
            else
            {
                hiderow1.Visible               = false;
                hiderow2.Visible               = false;
                hiderow3.Visible               = false;
                SubmitButton1.Visible          = false;
                SearchButton.Visible           = true;
                titleLabel.Text                = "Search Package";
                GridViewPackageDetails.Visible = false;
            }
        }
    }