采用datagrid显示数据表中的数据,datagrid分5行为一页。用一个标签显示,datagrid中的记录总数,可是总显示第一页的数目,不是实际数量。代码:lblCount1.Text = DataGrid1.Items.Count.ToString();
谁能告诉我这是怎么回事

解决方案 »

  1.   

    你直接将查询出来的数据放到lblCount1.Text 里面不行吗.DataGrid1.Items.Count.ToString();
    只是显示当前页的数量
      

  2.   

    我只是用下面的代码显示纪录,没有进行查询public void Bindgrid()
        {
            strsql = "select * from Commodity ";
            SqlDataAdapter sqlda = new SqlDataAdapter(strsql, con);
            DataSet ds = new DataSet();
            sqlda.Fill(ds);
            DataGrid1.DataSource = ds;
            DataGrid1.DataBind();
            lblCount.Text = DataGrid1.Items.Count.ToString();
        }
    color=#FF0000]这样该怎么显示所有记录的数量那?[[/color]
      

  3.   

    lblCount.Text =ds.Tables[0].Rows.Count就是总数量