<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" BorderWidth="1" Width="100%" BorderColor="#93BEE2" 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" />
<asp:BoundField HeaderText="全宗名称" DataField="WholeName" />
<asp:BoundField HeaderText="目录启止号" DataField="MenuStartEndID" />
<asp:BoundField HeaderText="启止年代" DataField="StartEndDatetime" />
<asp:BoundField HeaderText="合计档案" DataField="ThisTotal" />
<asp:BoundField HeaderText="永久档案" DataField="ThisForever" />
<asp:BoundField HeaderText="长期档案" DataField="ThisLong" />
<asp:BoundField HeaderText="短期档案" DataField="ThisShort" />
<asp:BoundField HeaderText="存放位置" DataField="SavePlace" />
<%--<asp:BoundField HeaderText="档案信息存储数字化情况" DataField="AsNumber" />--%>
<asp:TemplateField HeaderText="档案信息存储数字化情况">
<ItemTemplate>
<%# (DataBinder.Eval(Container.DataItem, "AsNumber").ToString().Length > 10) ? DataBinder.Eval(Container.DataItem, "AsNumber").ToString().Substring(0, 10) + "..." : DataBinder.Eval(Container.DataItem, "AsNumber").ToString()%>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField HeaderText="备注" DataField="Remark" />--%>
<asp:TemplateField HeaderText="备注">
<ItemTemplate>
<%# (DataBinder.Eval(Container.DataItem, "Remark").ToString().Length > 10) ? DataBinder.Eval(Container.DataItem, "Remark").ToString().Substring(0, 10) + "..." : DataBinder.Eval(Container.DataItem, "Remark").ToString()%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<div style="text-align:center">
<a href="CartularyWholeStatisticEdit.aspx?CartularyWholeStatisticID=<%# DataBinder.Eval(Container, "DataItem.CartularyWholeStatisticID")%>&PageIndex=<%=PageIndex%>">编辑</a> <a οnclick="return delconfirm()" href="CartularyWholeStatisticDele.aspx?CartularyWholeStatisticID=<%# DataBinder.Eval(Container, "DataItem.CartularyWholeStatisticID")%>&PageIndex=<%=PageIndex%>">删除</a>
</div>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#337FB2" Font-Bold="False" Font-Size="12px" ForeColor="White" Height="22px" />
<RowStyle Height="22px" Font-Size="12px" HorizontalAlign=Center />
<AlternatingRowStyle Height="22px" BackColor="#E8F4FF" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
DataControlRowType elemType = e.Row.RowType;
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow dgi = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
GridViewRow dgi1 = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
Table tb = new Table();
tb = (Table)GridView1.Controls[0];
tb.Rows.Clear();
tb.Rows.AddAt(0, dgi);
tb.Rows.AddAt(1, dgi1);
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 tc20 = new TableCell();
TableCell tc21 = new TableCell();
TableCell tc22 = new TableCell();
TableCell tc23 = new TableCell();
tc11.Text = "全宗号";
tc11.RowSpan = 2;
tc11.Height = 44;
tc11.Font.Bold = true;
tc11.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc11);
tc12.Text = "全宗名称";
tc12.Font.Bold = true;
tc12.HorizontalAlign = HorizontalAlign.Center;
tc12.RowSpan = 2;
dgi.Cells.Add(tc12);
tc13.Text = "目录启止号";
tc13.Font.Bold = true;
tc13.HorizontalAlign = HorizontalAlign.Center;
tc13.RowSpan = 2;
dgi.Cells.Add(tc13);
tc14.Text = "启止年代";
tc14.Font.Bold = true;
tc14.RowSpan = 2;
tc14.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc14);
tc15.Text = "档案数量(卷、件)";
tc15.Font.Bold = true;
tc15.HorizontalAlign = HorizontalAlign.Center;
tc15.ColumnSpan = 4;
dgi.Cells.Add(tc15);
tc16.Text = "存放位置";
tc16.Font.Bold = true;
tc16.HorizontalAlign = HorizontalAlign.Center;
tc16.RowSpan = 2;
dgi.Cells.Add(tc16);
tc17.Text = "档案信息存储数字化情况";
tc17.Font.Bold = true;
tc17.RowSpan = 2;
tc17.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc17);
tc18.Text = "备注";
tc18.Font.Bold = true;
tc18.HorizontalAlign = HorizontalAlign.Center;
tc18.RowSpan = 2;
dgi.Cells.Add(tc18);
tc19.Text = "";
tc19.HorizontalAlign = HorizontalAlign.Center;
tc19.RowSpan = 2;
dgi.Cells.Add(tc19);
tc20.Text = "合计";
tc20.Font.Bold = true;
tc20.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc20);
tc21.Text = "永久";
tc21.Font.Bold = true;
tc21.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc21);
tc22.Text = "长期";
tc22.Font.Bold = true;
tc22.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc22);
tc23.Text = "短期";
tc23.Font.Bold = true;
tc23.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc23);
int nColumn = e.Row.Cells.Count;
for (int i = 0; i < nColumn; i++)
{
e.Row.Cells.RemoveAt(0);
}
}
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) + 3, 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 ThisTotal, ThisForever, ThisLong, ThisShort;
ThisTotal = 0; ThisForever = 0; ThisLong = 0; ThisShort = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string temp1 = GridView1.Rows[i].Cells[4].Text.ToString();
if (temp1 == "") temp1 = "0";
ThisTotal += Convert.ToDecimal(temp1);
string temp2 = GridView1.Rows[i].Cells[5].Text.ToString();
if (temp2 == "") temp2 = "0";
ThisForever += Convert.ToDecimal(temp2);
string temp3 = GridView1.Rows[i].Cells[6].Text.ToString();
if (temp3 == "") temp3 = "0";
ThisLong += Convert.ToDecimal(temp3);
string temp4 = GridView1.Rows[i].Cells[7].Text.ToString();
if (temp4 == "") temp4 = "0";
ThisShort += Convert.ToDecimal(temp4);
}
tc11.Text = "合计";
//tc11.Font.Bold = true;
tc11.ForeColor = Color.Black;
tc11.BackColor = Color.White;
tc11.HorizontalAlign = HorizontalAlign.Center;
tc11.Height = 22;
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.ForeColor = Color.Black;
tc15.BackColor = Color.White;
tc15.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc15);
tc15.Text = ThisTotal.ToString();
tc16.ForeColor = Color.Black;
tc16.BackColor = Color.White;
tc16.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc16);
tc16.Text = ThisForever.ToString();
tc17.ForeColor = Color.Black;
tc17.BackColor = Color.White;
tc17.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc17);
tc17.Text = ThisLong.ToString();
tc18.ForeColor = Color.Black;
tc18.BackColor = Color.White;
tc18.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc18);
tc19.Text = "";
tc19.ForeColor = Color.Black;
tc19.BackColor = Color.White;
tc19.HorizontalAlign = HorizontalAlign.Center;
dgi2.Cells.Add(tc19);
tc18.Text = ThisShort.ToString();
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);
}
}
}