用sql, seelct A,Type,Amount,count(amount) as total from ** 动态创建datagrid列, <asp:BoundColumn DataField="a" HeaderText="a"></asp:BoundColumn> ... <asp:BoundColumn DataField="total" HeaderText="总计"></asp:BoundColumn>
To delectation(我是一只小小鸟) 估计楼主要的不是你设计的吧,你的每行都显示总和,他要的时列显示总和在页脚
seelct A,Type,Amount,count(amount) as total from **
动态创建datagrid列,
<asp:BoundColumn DataField="a" HeaderText="a"></asp:BoundColumn>
...
<asp:BoundColumn DataField="total" HeaderText="总计"></asp:BoundColumn>
估计楼主要的不是你设计的吧,你的每行都显示总和,他要的时列显示总和在页脚
在dataitembind中
x+=int.phase(e.item.cells[5].text);
然后在页脚显示此变量就可了
假如用的是DataGrid
for(int i=0;i<DataGrid.Items.Count;i++)
{
double aa = aa++;
}
Label.Text = aa.ToString();
for(int i=0;i<DataGrid.Items.Count;i++)
{
double aa += int.Parse(DataGrid.Items[i].toString());
}
Label.Text = aa.ToString();
for(int i=0;i<DataGrid.Items.Count;i++)
{
double aa += int.Parse(DataGrid.Items[i].toString());
}
Label.Text = aa.ToString();
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
int dd = 0;
for(int i= 0;i<DataGrid1.Items.Count;i++)
{
dd += int.Parse(DataGrid1.Items[i].Cells[6].Text.ToString());
}
DataGrid1.Columns[6].FooterText = dd.ToString();
}
页脚要显示才行