This article mainly uses CSS to display text on images. Copy the following code, paste it into a test file, and directly use a browser.
ASPX code
<% @ Page Language = "C #" EnableViewState = "false" %>
<! 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;
// Display fields for testing
Dt. Columns. Add (new System. Data. DataColumn ("January", typeof (System. String )));
Dt. Columns. Add (new System. Data. DataColumn ("February", typeof (System. String )));
Dt. Columns. Add (new System. Data. DataColumn ("March", typeof (System. String )));
// Test Progress data
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">
<Title> example of displaying progress pictures and progress text using GridView </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Asp: GridView ID = "GridView1" runat = "server" AutoGenerateColumns = "false">
<Columns>
<Asp: TemplateField HeaderText = "January">
<ItemTemplate>
<Div style = "position: relative; width: 200px;"> "height =" 20 "/> <br/>
<Div style = "width: 200px; position: absolute; z-index: 100; top: 0px; text-align: center;"> <% # Eval ("January ") %> </div>
</Div>
</ItemTemplate>
</Asp: TemplateField>
<Asp: TemplateField HeaderText = "February">
<ItemTemplate>
<Div style = "position: relative; width: 200px;"> "height =" 20 "/> <br/>
<Div style = "width: 200px; position: absolute; z-index: 100; top: 0px; text-align: center;"> <% # Eval ("February ") %> </div>
</Div>
</ItemTemplate>
</Asp: TemplateField>
<Asp: TemplateField HeaderText = "March">
<ItemTemplate>
<Div style = "position: relative; width: 200px;"> "height =" 20 "/> <br/>
<Div style = "width: 200px; position: absolute; z-index: 100; top: 0px; text-align: center;"> <% # Eval ("March ") %> </div>
</Div>
</ItemTemplate>
</Asp: TemplateField>
</Columns>
</Asp: GridView>
</Form>
</Body>
</Html>
Author: Meng xianhui