用DataList 控制元件开发的一个简单的留言本程序,用DataList 控制元件开发的一个简单的留言本程序
【 tulaoshi.com - ASP.NET 】
<%@ Import Namespace="System.Data" %<!--编号模版--
<template name="HeaderTemplate"
<asp:LinkButton id="Tosay" runat="server" Text="我要发言" ForeColor="#ffffff"/
<a href="temp.aspx"<font color="#ffffff"刷新界面</font</a
<asp:LinkButton id="Mange" runat="server" Text="管理留言" ForeColor="#ffffff"/
</template
<!--内容模版--
<template name="ItemTemplate"
<%# Container.DataItem("book_id")%
<%# Container.DataItem("content")%
<asp:LinkButton id="Detail" runat="server" Text="查看详细内容" ForeColor="#333333"/
</template
<!--查看留言模版--
<template name="SelectedItemTemplate"
编号: <%# Container.DataItem("book_id")%<BR
发言人: <%# Container.DataItem("username")%<BR
时间: <%# Container.DataItem("post_time")%<BR
内容: <%# Container.DataItem("content")%<BR
<div align="right"<asp:LinkButton id="Title" runat="server" Text="关闭" ForeColor="#333333"/</div
</template
</asp:DataList
<table id="foot" cellspacing=0 cellpadding=0 width="776" border=0 runat="server" visible="false"
<tr
<td bgcolor=#000000
<table cellspacing=1 cellpadding=3 width="100%" border=0
<tr bgcolor=#ffffff
<td大名:<Input Type="Text" id="Username" Size=20 runat="server" /<br
留言:<Input Type="Text" id="Content" Size=20 runat="server" /
<asp:LinkButton id="save" runat="server" Text="保存" OnClick="LinkButton1_Click" AutoPostBack/<br
<asp:LinkButton id="close" runat="server" Text="关闭" OnClick="LinkButton2_Click"/</td
</tr
</table
</td
</tr
</table
<table cellspacing=0 cellpadding=0 width="776" border=0
<tr
<td width="98%" bgcolor=#333333 align="center"<font face=宋体 color=#ffffcc<b 留言本</b</font</td
<td width="2%"<img height=20 src="http://img.jcwcn.com/attachment/portal/chinazcj/2005-11/19/05111911284879793.gif" width=16</td
</tr
</table
</Form
<hr
<asp:Label id="Label1" runat="server" /
</Body
</Html
<script Language="VB" runat="server"
Sub Page_Load(sender As Object, e As EventArgs)
DataList1.DataSource = CreateDataView( "data.mdb", "guestbook" )
DataList1.DataBind()
End Sub
Function CreateDataView( Db As String, Table As String ) As DataView
Dim Provider, ConnStr, SQL As String
Provider = "Microsoft.Jet.OLEDB.4.0;"
ConnStr = "Provider=" & Provider & _
"Data Source=" & Server.MapPath( Db )
Dim Cmd As ADODataSetCommand
Cmd = New ADODataSetCommand( "Select * from " & Table &" Order By post_time DESC", ConnStr )
Dim ds As DataSet = new DataSet()
Cmd.FillDataSet(ds, Table)
CreateDataView = new Da
来源:http://www.tulaoshi.com/n/20160129/1491765.html
看过《用DataList 控制元件开发的一个简单的留言本程序》的人还看了以下文章 更多>>