protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                string command = SqlDataSource1.SelectCommand; // added just for debug purpose
                _sql2 = Convert.ToString(Session["_sql_"]);
                if (_Sql == null || _Sql == "")
                {
                    _Sql = command;
                }
                if (_sql2 != null || _sql2 != "")
                {
                    SqlDataSource1.SelectCommand = _sql2;
                    SqlDataSource1.DataBind();
                    GridView_Confirming.DataBind();
                }
            }
            else if (!this.IsPostBack)
            {
                ShowData();
            }

            /* if (!this.IsPostBack)
             * {
             *   //gvUsuarios.DataSource = con.seleccion("select * from usuarios");
             *   string command = SqlDataSource1.SelectCommand; // added just for debug purpose
             *   if (_Sql == null || _Sql == "")
             *   {
             *       _Sql = command;
             *
             *   }
             *   SqlDataSource1.DataBind();
             *   GridView_Confirming.DataBind();
             * }*/
        }
 protected void btnQuitarSeleccionados_Click(object sender, EventArgs e)
 {
     //Recorrer las filas del GridView...
     foreach (GridViewRow row in GridView_Confirming.Rows)
     {
         if (row.RowType == DataControlRowType.DataRow)
         {
             CheckBox CheckBoxElim = row.FindControl("chkEliminar") as CheckBox;
             if (CheckBoxElim.Checked)
             {
                 GridView_Confirming.DeleteRow(row.RowIndex);
             }
         }
     }
     GridView_Confirming.DataBind();
 }
        protected void ShowData()
        {
            SqlDataSource1.SelectCommand = _sql2;
            SqlDataSource1.DataBind();
            GridView_Confirming.DataBind();

            /*  dt = new DataTable();
             * con = new SqlConnection(cs);
             * con.Open();
             * adapt = new SqlDataAdapter("Select ID,Name,City from tbl_Employee", con);
             * adapt.Fill(dt);
             * if (dt.Rows.Count > 0)
             * {
             *    GridView1.DataSource = dt;
             *    GridView1.DataBind();
             * }
             * con.Close();*/
        }
        private void datos_2_grid(int tipo)
        {
            string sql = @"SELECT [ID]
      ,Convert(varchar,[FECHA_EMISION],103) as [FECHA_EMISION]
      ,[ENTIDAD]
      , Convert(varchar,[FECHA_PAGO],103) as [FECHA_PAGO]
      ,[PROVEEDOR]
      ,[N_FACTURA]
      ,[EMPRESA]
      ,[IMPORTE]
      ,Convert(varchar,[FECHA_VENCIMIENTO],103) as [FECHA_VENCIMIENTO]
      ,[MES_VENCIMIENTO]
      ,[NOMINAL]
      ,[PAGADO] FROM [CONFIRMING]";

            switch (tipo)
            {
            case 1:
                sql = sql + " WHERE [FECHA_EMISION] between convert(datetime,'" + datepicker_1.Text + "',103) and  convert(datetime,'" + datepicker_2.Text + "',103)";
                break;

            case 2:
                sql = sql + " WHERE [FECHA_PAGO] between convert(datetime,'" + datepicker_1b.Text + "',103) and  convert(datetime,'" + datepicker_2b.Text + "',103)";
                break;

            case 3:
                sql = sql + " WHERE [FECHA_VENCIMIENTO] between convert(datetime,'" + datepicker_1c.Text + "',103) and  convert(datetime,'" + datepicker_2c.Text + "',103)";
                break;

            case 4:
                string a = Request.Form["ctl00$MainContent$txtEntidad_"].ToString().Trim().Replace("\r", "").Replace("\n", "");
                sql = sql + " Where ENTIDAD like '%" + Request.Form["ctl00$MainContent$txtEntidad_"].ToString().Trim().Replace("\r", "").Replace("\n", "") + @"%'";
                break;
            }
            _Sql                              = sql;
            _sql2                             = sql;
            Session["_sql_"]                  = sql;
            SqlDataSource1.SelectCommand      = sql;
            GridView_Confirming.PageIndex     = 0;
            GridView_Confirming.EditIndex     = -1;
            GridView_Confirming.SelectedIndex = -1;
            GridView_Confirming.DataBind();
            Panel_grid.Visible = true;
        }
 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GridView_Confirming.PageIndex = e.NewPageIndex;
     GridView_Confirming.DataBind();
 }