using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace GuestBook
{
/// <summary>
/// View 的摘要说明。
/// </summary>
public class View : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Repeater Message;
int pageSize,recordCount,pageCount,currentPage;
protected System.Web.UI.WebControls.Label lbRecordCount;
protected System.Web.UI.WebControls.Label lbCurrentPage;
protected System.Web.UI.WebControls.Label lbPageCount;
protected System.Web.UI.WebControls.LinkButton butPrev;
protected System.Web.UI.WebControls.LinkButton butNext;
protected System.Web.UI.WebControls.DropDownList dlsPageIndex;
OleDbConnection conn;
private void Page_Load(object sender, System.EventArgs e)
{
OleDbConnection conn;
OleDbCommand comd;
string sql;
DataSet ds;
OleDbDataAdapter da;
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + "..\\Data\\data.mdb";
conn = new OleDbConnection(conStr);
sql = "Select * from GuestBook order by date DESC";
da = new OleDbDataAdapter(sql,conn);
ds = new DataSet();
da.Fill(ds,1,5,"Message");
Message.DataSource = ds;
Message.DataMember = "Message";
Message.DataBind();
conn.Close();
}
}
}
<%@ Page Language="c#" AutoEventWireup="false" src="2.aspx.cs" Inherits="GuestBook.View"%>
<html><body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<ASP:Repeater id="Message" runat="server"> <HeaderTemplate> <table width="100%" style="font: 8pt verdana">
<tr style="background-color:DFA894">
<th>
Title
</th>
<th>
Title ID
</th>
<th>
Type
</th>
<th>
Publisher ID
</th>
<th>
Price
</th>
</tr> </HeaderTemplate> <ItemTemplate> <tr style="background-color:FFECD8">
<td>
<%# DataBinder.Eval(Container.DataItem,"Photo")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo", "$ {0}") %>
</td>
</tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </ASP:Repeater> </body>
</html>
改了。
不过运行 没有信息啊出现啊
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace GuestBook
{
/// <summary>
/// View 的摘要说明。
/// </summary>
public class View : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Repeater Message;
int pageSize,recordCount,pageCount,currentPage;
protected System.Web.UI.WebControls.Label lbRecordCount;
protected System.Web.UI.WebControls.Label lbCurrentPage;
protected System.Web.UI.WebControls.Label lbPageCount;
protected System.Web.UI.WebControls.LinkButton butPrev;
protected System.Web.UI.WebControls.LinkButton butNext;
protected System.Web.UI.WebControls.DropDownList dlsPageIndex;
OleDbConnection conn;
private void Page_Load(object sender, System.EventArgs e)
{
OleDbConnection conn;
OleDbCommand comd;
string sql;
DataSet ds;
OleDbDataAdapter da;
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + "..\\Data\\data.mdb";
conn = new OleDbConnection(conStr);
sql = "Select * from GuestBook order by date DESC";
da = new OleDbDataAdapter(sql,conn);
ds = new DataSet();
da.Fill(ds,1,5,"Message");
Message.DataSource = ds;
Message.DataMember = "Message";
Message.DataBind();
conn.Close();
}
}
}
<%@ Page Language="c#" AutoEventWireup="false" src="2.aspx.cs" Inherits="GuestBook.View"%>
<html><body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<ASP:Repeater id="Message" runat="server"> <HeaderTemplate> <table width="100%" style="font: 8pt verdana">
<tr style="background-color:DFA894">
<th>
Title
</th>
<th>
Title ID
</th>
<th>
Type
</th>
<th>
Publisher ID
</th>
<th>
Price
</th>
</tr> </HeaderTemplate> <ItemTemplate> <tr style="background-color:FFECD8">
<td>
<%# DataBinder.Eval(Container.DataItem,"Photo")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Photo", "$ {0}") %>
</td>
</tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </ASP:Repeater> </body>
</html>
改了。
不过运行 没有信息啊出现啊
---><%@ Page Language="c#" AutoEventWireup="false" Codebehind="2.aspx.cs" AutoEventWireup="false" Inherits="GuestBook.View"%>
注意src
AutoEventWireup="true"
AutoEventWireup 属性的缺点是它要求页事件处理程序具有特定、可预测的名称。这限制了您在为事件处理程序命名时的灵活性。因此,在 Visual Studio 中,AutoEventWireup 属性在默认情况下设置为 false,设计器会生成用于将页事件绑定到方法的显式代码。 如果将 AutoEventWireup 设置为 true,Visual Studio 将生成用于绑定事件的代码,页框架将自动基于事件的名称来调用事件。这可能会导致在该页运行时两次调用相同的事件代码。因此,当在 Visual Studio 中操作时,应尽量使 AutoEventWireup 设置为 false。
msdn有解释