日期:2014-05-18 浏览次数:20542 次
<%@ 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"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { System.Data.DataTable dt = new System.Data.DataTable(); System.Data.DataRow dr; dt.Columns.Add(new System.Data.DataColumn("3月13日", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("3月14日", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("3月15日", typeof(System.String))); String[] x = { "10%", "20%", "50%", "80%", "90%","100%" }; Random r = new Random(); for (int i = 0; i < 8; i++) { dr = dt.NewRow(); dr[0] = x[r.Next(0, x.Length)]; dr[1] = x[r.Next(0, x.Length)]; dr[2] = x[r.Next(0, x.Length)]; dt.Rows.Add(dr); } GridView1.DataSource = dt; GridView1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="3月13日"> <ItemTemplate> <div style="height:0px;text-align:center"><span style="position:relative;top:0px;z-index:10;height:20px;"><%#Eval("3月13日") %></span></div> <div style="width:200px;position:relative;"><img alt="" src="http://livedocs.adobe.com/flex/3_cn/langref/images/createGradientBox-2.jpg" width="<%#Eval("3月13日") %>" height="20" /></div> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="3月14日"> <ItemTemplate> <div style="height:0px;text-align:center"><span style="position:relative;top:0px;z-index:10;height:20px;"><%#Eval("3月14日") %></span></div> <div style="width:200px;position:relative;"><img alt="" src="http://livedocs.adobe.com/flex/3_cn/langref/images/createGradientBox-2.jpg" width="<%#Eval("3月14日") %>" height="20" /></div> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="3月15日"> <ItemTemplate> <div style="height:0px;text-align:center"><span style="position:relative;top:0px;z-index:10;height:20px;"><%#Eval("3月15日") %></span></div> <div style="width:200px;position:relative;"><img alt="" src="http://livedocs.adobe.com/flex/3_cn/langref/images/createGradientBox-2.jpg" width="<%#Eval("3月15日") %>" height="20" /></div> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> </body> </html>