<%@ 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>如何可以在img里面加上文字呢?我加了之后就是显示不出来
<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>如何可以在img里面加上文字呢?我加了之后就是显示不出来
<table><tr><td style="backgroud-img('img/1.jpg')"> 文字</td></tr></table>