Ejemplo n.º 1
0
        private void UpdateGridView()
        {
            SqlConnection  conn = new SqlConnection(@"data source = .\SQLEXPRESS; integrated security = true; database = Pokemons");
            SqlDataAdapter da   = null;
            DataSet        ds   = null;
            DataTable      dt   = null;

            string sqlsel = "SELECT PokemonNumber,PokemonName,NextEvulotion,PictureLink FROM Pokemons";

            try
            {
                da = new SqlDataAdapter(sqlsel, conn);
                ds = new DataSet();
                dt = new DataTable();

                da.Fill(ds, "MyPokemons");
                dt = ds.Tables["MyPokemons"];

                GridViewAdd.DataSource = dt;
                GridViewAdd.DataBind();
            }
            catch (Exception ex)
            {
                LabelMessageAdd.Text = ex.Message;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Ejemplo n.º 2
0
    }//反选

    #endregion
    #region//绩效考核员工新增栏的翻页

    protected void GridViewAdd_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView theGrid      = sender as GridView; // refer to the GridView
        int      newPageIndex = 0;

        if (-2 == e.NewPageIndex)
        {
            TextBox     txtNewPageIndex = null;
            GridViewRow pagerRow        = GridViewAdd.BottomPagerRow;


            if (null != pagerRow)
            {
                txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox4");   // refer to the TextBox with the NewPageIndex value
            }

            if (null != txtNewPageIndex && txtNewPageIndex.Text != "")
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }
        if (LabelForAddEmployee.Text == "检索前")
        {
            BindGridForEmployee(GridViewAdd, " and HRPAT_ID is null");
        }
        if (LabelForAddEmployee.Text == "检索后")
        {
            BindGridForEmployee(GridViewAdd, con2 + " and HRPAT_ID is null");
        }
        newPageIndex          = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex          = newPageIndex >= GridViewAdd.PageCount ? GridViewAdd.PageCount - 1 : newPageIndex;
        GridViewAdd.PageIndex = newPageIndex;
        GridViewAdd.PageIndex = newPageIndex;
        GridViewAdd.DataBind();
    }//GridViewAdd进行翻页