示例#1
0
    //翻页
    protected void Grid_ControlItems_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        = Grid_ControlItems.BottomPagerRow;


            if (null != pagerRow)
            {
                txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox");   // 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;
        }
        BindGridview(Bindc1, Bindc2);
        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= Grid_ControlItems.PageCount ? Grid_ControlItems.PageCount - 1 : newPageIndex;
        Grid_ControlItems.PageIndex = newPageIndex;
        Grid_ControlItems.DataBind();
    }
示例#2
0
    //排序
    protected void Grid_ControlItems_Sorting(object sender, GridViewSortEventArgs e)
    {
        // 从事件参数获取排序数据列

        string sortExpression = e.SortExpression.ToString();

        // 假定为排序方向为“顺序”

        string sortDirection = "ASC";

        // “ASC”与事件参数获取到的排序方向进行比较,进行GridView排序方向参数的修改

        if (sortExpression == Grid_ControlItems.Attributes["SortExpression"])
        {
            //获得下一次的排序状态

            sortDirection = (Grid_ControlItems.Attributes["SortDirection"].ToString() == sortDirection ? "DESC" : "ASC");
        }

        // 重新设定GridView排序数据列及排序方向

        Grid_ControlItems.Attributes["SortExpression"] = sortExpression;

        Grid_ControlItems.Attributes["SortDirection"] = sortDirection;

        //重新绑定数据

        Grid_ControlItems.DataBind();
    }
示例#3
0
 //绑定管制项目Gridview
 private void BindGridview(string condition1, string condition2)
 {
     Grid_ControlItems.DataSource = hSFBasicDataL.Search_HSFContrItems(condition1, condition2);
     Grid_ControlItems.DataBind();
 }