查询结果用datagrid显示,怎么知道datagrid显示的总页数,总记录数,当前是第几页,等!!!

解决方案 »

  1.   

    好像控件datagrid可以设定这种格式
      

  2.   

    int PageCount=DataGrid1.PageCount;
    int currentPage=DataGrid1.CurrentPageIndex+1;
      

  3.   

    public int CalculateRecord()
    {
    //返回留言总数
    int Count;
    string countStr;
    if(sTitle==null)
    {
    countStr = "Select count(*) as Total from news";
    }
    else
    {
    countStr = "Select count(*) as Total from news where cateid=" + int.Parse(sTitle);
    }
    conn.Open();
    OleDbCommand comm = new OleDbCommand(countStr,conn);
    OleDbDataReader dr = comm.ExecuteReader();
    if(dr.Read())
    {
    Count = int.Parse(dr["Total"].ToString());
    }
    else
    {
    Count = 0;
    }
    conn.Close();
    dr.Close();
    return Count;
    }pageCount = recordCount / pageSize; // 计算共有多少页
      

  4.   

    微软快速入门:
    http://chs.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/datagrid10.src