這個幾乎就跟作者的一模一樣,只是我是用vs2005,作者用的是vs2003,只是簡化了,因爲有的我不懂什麼意思.不知道是不是必須的
list.aspx源碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="list.aspx.cs" Inherits="News_list" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無標題頁</title>
</head>
<body>
<form id="form1" runat="server">
<table width="780" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="788" height="150" bgcolor="#FFFFFF">網站頂部(<span class="style3"> <span class="style7">爍空 </span><a href="http://www.socut.com" target="_blank" class="style7">www.<span class="style11"><span class="style12">so</span>cut</span>.com</a> </span>)
本教程爲ACCESS版新聞系統速成教程,完全免費。<br>如果對本教程滿意,而且想學SQL Server版的新聞系統開發方式,則需要付費購買。
<br>
爲什麼要購買?付費教程兩個特色:
<br>1,無須引入命名空間、無須實例化類,手寫代碼量節省至15%
<br>2,開發出來的系統自動具備Access與SQL Server兩種數據庫類型
<br>詳情訪問http://www.socut.com/dll/sql 客服QQ:5941011
</td>
</tr>
</table>
<table width="780" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#FFFFFF">
<td width="180" height="200">用戶登陸</td>
<td rowspan="2" valign="top">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href='edit.aspx?id=<%#DataBinder.Eval(Container.DataItem,"n_id")%>' target=_blank>
編輯</a> ·<a href='view.aspx?id=<%#DataBinder.Eval(Container.DataItem,"n_id")%>' target=_blank><%#DataBinder.Eval(Container.DataItem,"n_title")%></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="200">文章統計</td>
</tr>
</table>
<table width="780" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="788" height="150" align="center" bgcolor="#FFFFFF">網站底部</td>
</tr>
</table>
<div>
</div>
</form>
</body>
</html>
代碼如下 :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class News_list : System.Web.UI.Page
{
public Socut myData = new Socut();
public DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
ds = myData.GetDataSet("SELECT * FROM socut_news", 0, 0, "TableName");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
摘自網易的一個教程,只是自己猜寫了一個數據操作類,不用作者的組件,最後達到同樣的效果.建議初學者去下載!