我在项目中写了一个手工绑定DataGrid的方法。代码如下:
this.DataGrid1.Columns[1].FooterText = string.Format("{0}", this.dt.Compute("SUM(total)", null));
this.DataGrid1.Columns[2].FooterText = string.Format("{0:c}", this.dt.Compute("SUM(amount)", null));
this.DataGrid1.Columns[3].FooterText = string.Format("{0:c}", this.dt.Compute("SUM(paid)", null));
this.DataGrid1.Columns[4].FooterText = string.Format("{0:c}", this.dt.Compute("SUM(unpaid)", null));
this.Fill_DataGrid(this.DataGrid1, this.dt, true);
这里的Fill_DataGrid方法如果放在前面就不能显示FooterText的值,要刷新两次才显示出来。后到后面就可以。