日期:2014-05-18 浏览次数:20537 次
<%@ 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("postId", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("postTime", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("postTitle", typeof(System.String))); for (int i = 0; i < 8; i++) { dr = dt.NewRow(); dr[0] = i.ToString(); dr[1] = (i * i).ToString(); dr[2] = (i * i * i).ToString(); 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:HyperLinkField DataNavigateUrlFields="postId,postTime" DataNavigateUrlFormatString="http://dotnet.aspx.cc/Default.aspx?postId={0}&postTime={1}" DataTextField="postTitle" HeaderText="标题"> </asp:HyperLinkField> </Columns> </asp:GridView> </form> </body> </html>
------解决方案--------------------