int nRowCount =DataGrid1.Items.Count;

解决方案 »

  1.   

    为什么不用DataGrid1.Items.Count??
      

  2.   

    你在将DataGrid1.Controls[0]转换成Table时,Table自带了一个TR和TD,所以统计时多了一行!
      

  3.   

    你这样Table t = (Table)DataGrid1.Controls[0];获得的Table是包含了datagrid的页眉、页脚和分隔符等行,你说的最后一行可能是页脚或Pager行.要获取datagrid的数据行,就是楼上说的:
    int nRowCount =DataGrid1.Items.Count;DataGrid1.Items属性,只有绑定到数据源的项才包含在 Items 集合中。页眉、页脚和分隔符不包含在该集合中。
      

  4.   

    Beacause the datagrid's header and rooter are table row ,too.
    though you don't make the rooter visible,it's still exist.
      

  5.   

    同意 chnking(kent) 的解释
      

  6.   

    回答得都很好的,我想改变grid中的值,如何做呢?给个小粒子吧!
    谢谢!!
    马上给分!