日期:2014-05-17 浏览次数:20429 次
<h2>PC</h2> <DIV> <a href="20120628082911.pdf">123测试</a> <a href="20120628682715.pdf">酸辣白菜</a> <a href="20120628082718.pdf">土豆</a> </DIV> <h2>NC</h2> <DIV> <a href="20120628082761.pdf">豆角</a> <a href="20120628032711.pdf">茄子</a> </DIV>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> System.Data.DataTable dataTable1 = new System.Data.DataTable(); protected void Page_Load(object sender, EventArgs e) { dataTable1.Columns.Add(new System.Data.DataColumn("Id", typeof(System.Int32))); dataTable1.Columns.Add(new System.Data.DataColumn("Menu1", typeof(System.String))); dataTable1.Columns.Add(new System.Data.DataColumn("Menu2", typeof(System.String))); dataTable1.Columns.Add(new System.Data.DataColumn("URL", typeof(System.String))); dataTable1.Rows.Add(new Object[] { 1, "PC", "123测试", "20120628082911.pdf" }); dataTable1.Rows.Add(new Object[] { 2, "PC", "酸辣白菜", "20120628682715.pdf" }); dataTable1.Rows.Add(new Object[] { 3, "PC", "土豆", "20120628082718.pdf" }); dataTable1.Rows.Add(new Object[] { 4, "NC", "豆角", "20120628082761.pdf" }); dataTable1.Rows.Add(new Object[] { 5, "NC", "茄子", "20120628032711.pdf" }); System.Data.DataView dv = dataTable1.DefaultView; System.Data.DataTable dataTable2 = dv.ToTable(true, "Menu1"); System.Data.DataTable dataTable3 = dataTable1.Clone(); this.Repeater1.DataSource = dataTable1.DefaultView.ToTable(true, "Menu1"); this.Repeater1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[0].Text.Trim().Equals("合计")) { e.Row.Style.Add("color", "#d00"); } else if (e.Row.Cells[0].Text.Trim().Equals("总合计")) { e.Row.Style.Add("color", "#00d"); e.Row.Style.Add("background", "#f33"); } } protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater Repeater2 = e.Item.FindControl("Repeater2") as Repeater; String Menu1 = DataBinder.Eval(e.Item.DataItem, "Menu1").ToString(); System.Data.DataView dv = dataTable1.DefaultView; dv.RowFilter = "Menu1='" + Menu1 + "'"; Repeater2.Data