日期:2014-05-18 浏览次数:20534 次
<%@ 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) { System.Data.DataTable dt = new System.Data.DataTable(); if (!Page.IsPostBack) { System.Data.DataRow dr; dt.Columns.Add(new System.Data.DataColumn("id", typeof(System.Int32))); dt.Columns.Add(new System.Data.DataColumn("title", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("date", typeof(System.DateTime))); System.Random rd = new System.Random(); for (int i = 0; i < 6; i++) { dt.Rows.Add(new Object[] { i, "孟" + i.ToString(), DateTime.Now }); } GridView1.DataSource = dt; GridView1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:HyperLinkField DataTextField="date" DataTextFormatString="{0:yyyy年MM月dd日}" DataNavigateUrlFields="id,title" DataNavigateUrlFormatString="xx.aspx?id={0}&title={1}" /> </Columns> </asp:GridView> </form> </body> </html>