编程开发 > ASP > 文章内容

利用ASP.NET3.5的路由功能创建搜索引擎友好的URL(7)

2010-10-20编辑:dan

ArticleList.aspx

 


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<mce:script runat="server"><!--
protected void Page_Load(object sender, EventArgs e)
{
String ConnectionString = "Data Source=(local);Initial Catalog=ArticleDev;User ID=sa;Password=sa";
SqlConnection cn = new SqlConnection(ConnectionString);
cn.Open();
String sql = "Select * From Article Order By ArticleId DESC";
SqlCommand cmd = new SqlCommand(sql, cn);
SqlDataReader dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
cn.Dispose();
}
// --></mce: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 DataNavigateUrlFields="ArticleId" DataTextField="Title"
DataNavigateUrlFormatString="~/Article/{0}/read.aspx" HeaderText="标题" />
<asp:BoundField DataField="CreateDate" HtmlEncode="false" HeaderText="发布日期"
DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" />
</Columns>
</asp:GridView>
</form>
</body>
</html>

 

利用ASP.NET3.5的路由功能创建搜索引擎友好的URL(6)

热点推荐

登录注册
触屏版电脑版网站地图