<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" BorderWidth="1" Width="100%" BorderColor="Black" BorderStyle="Solid" CellPadding="0" Font-Size="12px" ForeColor="Black" PageIndex="0" AllowPaging=true PageSize="15" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:BoundField HeaderText="全宗号" DataField="WholeID" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode=False >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="目录号" DataField="MenuID" />
<asp:BoundField HeaderText="全宗名称" DataField="WholeName" />
<asp:BoundField HeaderText="类目名称" DataField="TypeName" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode=False />
<asp:BoundField HeaderText="启止年代" DataField="BeginToEndDateTime" />
<asp:BoundField HeaderText="保管期限" DataField="SaveTme" />
<asp:BoundField HeaderText="案卷数(卷、件)" DataField="RecordsNumber" />
<asp:BoundField HeaderText="盒数" DataField="BoxNumber" />
<asp:BoundField HeaderText="存放地址" DataField="SetAddress" />
<asp:BoundField HeaderText="利用形式" DataField="UsingStyle" />
<asp:BoundField HeaderText="备注" DataField="Remark" />
</Columns>
<HeaderStyle BackColor="White" Font-Bold="False" Font-Size="12px" ForeColor="Black" Height="22px" />
<RowStyle Height="22px" Font-Size="12px" HorizontalAlign="Center" />
<AlternatingRowStyle Height="22px" BackColor="White" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
/
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
DataControlRowType elemType = e.Row.RowType;
if (e.Row.RowType == DataControlRowType.Footer)
{
GridViewRow dgi2 = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
Table tb = new Table();
tb = (Table)GridView1.Controls[0];
tb.Rows.AddAt(Convert.ToInt32(GridView1.Rows.Count) + 1, dgi2);
TableCell tc11 = new TableCell();
TableCell tc12 = new TableCell();
TableCell tc13 = new TableCell();
TableCell tc14 = new TableCell();
TableCell tc15 = new TableCell();
TableCell tc16 = new TableCell();
TableCell tc17 = new TableCell();
TableCell tc18 = new TableCell();
TableCell tc19 = new TableCell();
TableCell tc110 = new TableCell();
TableCell tc111 = new TableCell();
//计算合计
decimal RecordsNumber, BoxNumber;
RecordsNumber = 0; BoxNumber = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string temp1 = GridView1.Rows[i].Cells[6].Text.ToString();
if (temp1 == "") temp1 = "0";
RecordsNumber += Convert.ToDecimal(temp1);
string temp2 = GridView1.Rows[i].Cells[7].Text.ToString();
if (temp2 == "") temp2 = "0";
BoxNumber += Convert.ToDecimal(temp2);
}
tc11.Text = "合计";
tc11.Font.Bold = true;
tc11.ForeColor = Color.Black;
tc11.BackColor = Color.White;
tc11.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc11);
tc12.Text = "";
tc12.ForeColor = Color.Black;
tc12.BackColor = Color.White;
tc12.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc12);
tc13.Text = "";
tc13.ForeColor = Color.Black;
tc13.BackColor = Color.White;
tc13.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc13);
tc14.Text = "";
tc14.ForeColor = Color.Black;
tc14.BackColor = Color.White;
tc14.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc14);
tc15.Text = "";
tc15.ForeColor = Color.Black;
tc15.BackColor = Color.White;
tc15.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc15);
tc16.Text = "";
tc16.ForeColor = Color.Black;
tc16.BackColor = Color.White;
tc16.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc16);
tc17.ForeColor = Color.Black;
tc17.BackColor = Color.White;
tc17.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc17);
tc17.Text = RecordsNumber.ToString();
tc18.ForeColor = Color.Black;
tc18.BackColor = Color.White;
tc18.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc18);
tc18.Text = BoxNumber.ToString();
tc19.Text = "";
tc19.ForeColor = Color.Black;
tc19.BackColor = Color.White;
tc19.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc19);
tc110.Text = "";
tc110.ForeColor = Color.Black;
tc110.BackColor = Color.White;
tc110.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc110);
tc111.Text = "";
tc111.ForeColor = Color.Black;
tc111.BackColor = Color.White;
tc111.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc111);
int nColumn = e.Row.Cells.Count;
for (int i = 0; i < nColumn; i++)
{
e.Row.Cells.RemoveAt(0);
}
}
}