http://dotnet.aspx.cc/ShowDetail.aspx?id=B12283DE-DB20-4322-ACCC-12724442808A

解决方案 »

  1.   

    SELECT COUNT(*) FROM yourtablecmd.Connection.Open();
    // 用这方法取出记录总数!
             iRet = ((int) cmd.ExecuteScalar());
             cmd.Connection.Close();
      

  2.   

    SELECT count(8)FROM yourdatabase;
    OleDbDataAdapter da=new OleDbDataAdapter(strcmd,con);
    DataSet ds=new DataSet();
    da.Fill(ds,"yourtable");
    string totalcount =ds["yourtable"].Rows.Count.Tostring();
      

  3.   

    sorry 8 should be *,sorry!
      

  4.   

    net_lover(孟子E章):
       你的里面仿佛没有计算记录数的,不信你进去看看
     cuike519(Knowledge is Power) :
      我说老兄你开玩笑呢,我想问的是有没有这个属性,如果这样写,我还来问什么啊
      

  5.   

    天那,今天怎么了
    你们看看,有没有这个属性,如:
    ImgGrid.PageCount.ToString() 之类的!
      

  6.   

    ----------------------------------------
    cuike519(Knowledge is Power) :
      我说老兄你开玩笑呢,我想问的是有没有这个属性,如果这样写,我还来问什么啊
    -----------------------------------------------------------有这个属性啊?怎么会没有?
    cuike519(Knowledge is Power) 的那个cmd是 SqlCommand
    不过那个ExecuteScalar()具体是什么意思我就不知道了。但是结果是正确的。
      

  7.   

    LaRecordCount.Text = 
    "总共  <font color=#3300ff><B>" 
    +ImgGrid.VirtualItemCount
    +"</B></font> 条记录";
      

  8.   

    daihaidong(东) :
    结果是0??
      

  9.   

    我的方法不行吗?就算不行greennetboy(绿色家园) 的也应该可以!
    VirtualItemCount:Gets or sets the virtual number of items in the DataGrid control when custom paging is used.
    也就是你要设置AllowCustomPaging=true才能得到这里面的值!
      

  10.   

    要看你的DataSource是什么了,如果你的DataGrid的DataSource是DataView,则可以通过DataView的属性Count来获得纪录的条数。
    当然你也可以计算出总纪录:
    int Count = ImgGrid.PageSize * (ImgGrid.PageCount-1) + ImgGrid.Items[ImgGrid.PageCount-1].Count;
      

  11.   

    谢谢KongXiangxin(风卷残云) 
    可以结帖了!