📄 simple-repeater-template.aspx
字号:
<%@Page Language="C#"%>
<%@Import Namespace="System.Data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Using a Simple Template with a Repeater Control</title>
<style type="text/css">
body, td {font-family:Tahoma,Arial,sans-serif; font-size:10pt}
input {font-family:Tahoma,Arial,sans-serif; font-size:9pt}
.heading {font-family:Tahoma,Arial,sans-serif; font-size:14pt; font-weight:bold}
.subhead {font-family:Tahoma,Arial,sans-serif; font-size:12pt; font-weight:bold; padding-bottom:5px}
.cite {font-family:Tahoma,Arial,sans-serif; font-size:8pt}
.rHead {font-family:Lucida Handwriting,Comic Sans MS,Tahoma,Arial;
font-size:14pt; font-weight:bold; padding:8px; color:green}
.rItem {font-family:Lucida Handwriting,Comic Sans MS,Tahoma,Arial,sans-serif;
font-size:10pt}
.rFoot {font-family:Tahoma,Arial; font-size:8pt; padding:8px; color:darkgray}
</style></head>
<body bgcolor="#ffffff">
<span class="heading">Using a Simple Template with a Repeater Control</span><hr />
<!--------------------------------------------------------------------------->
<ASP:Repeater id="MyRepeater" runat="server">
<HeaderTemplate>
<div class="rHead">
Some of the Latest Wrox Press Books<br />
<img src="images/redrule.gif">
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="rItem">
<img src="images/<%# DataBinder.Eval(Container.DataItem, "ImageURL") %>"
align="left" hspace="10" />
<b><%# DataBinder.Eval(Container.DataItem, "Title") %></b><br />
ISBN: <%# DataBinder.Eval(Container.DataItem, "ISBN") %> +nbsp;
Published: <%# DataBinder.Eval(Container.DataItem,
"PublicationDate", "{0:d}") %><br />
<%# DataBinder.Eval(Container.DataItem, "Precis") %>
</div><br clear="all" />
</ItemTemplate>
<SeparatorTemplate>
<img src="images/redrule.gif">
</SeparatorTemplate>
<FooterTemplate>
<img src="images/redrule.gif">
<div class="rFoot">
For more information visit <a href="http://www.wrox.com">http://www.wrox.com</a>
</div>
</FooterTemplate>
</ASP:Repeater><p />
<!--------------------------------------------------------------------------->
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
// create a new empty DataTable object
DataTable objTable = new DataTable("NewTable");
// define four columns (fields) within the table
objTable.Columns.Add("ISBN", Type.GetType("System.String"));
objTable.Columns.Add("Title", Type.GetType("System.String"));
objTable.Columns.Add("PublicationDate", Type.GetType("System.DateTime"));
objTable.Columns.Add("ImageURL", Type.GetType("System.String"));
objTable.Columns.Add("Precis", Type.GetType("System.String"));
// declare a variable to hold a DataRow object
DataRow objDataRow;
// create a new DataRow object instance in this table
objDataRow = objTable.NewRow();
// and fill in the values
objDataRow["ISBN"] = "1861004478";
objDataRow["Title"] = "Professional Application Center 2000";
objDataRow["PublicationDate"] = "2001-03-01";
objDataRow["ImageURL"] = "appcenter.gif";
objDataRow["Precis"] = "This book takes you through the complete process of setting up "
+ "and creating Web clusters and component clusters, adapting your applications to "
+ "work in a clustered scenario, and how you can administer and monitor them.";
objTable.Rows.Add(objDataRow);
objDataRow = objTable.NewRow();
objDataRow["ISBN"] = "1861004753";
objDataRow["Title"] = "A Preview of ASP+";
objDataRow["PublicationDate"] = "2000-07-01";
objDataRow["ImageURL"] = "aspplus.gif";
objDataRow["Precis"] = "Active Server Pages (ASP.NET) makes it easier, faster and less "
+ "error-prone to write your own Web applications and dynamic Web pages. In a lot "
+ "of cases, there is actually less code to write - and sometime none at all. ";
objTable.Rows.Add(objDataRow);
objDataRow = objTable.NewRow();
objDataRow["ISBN"] = "1861004028";
objDataRow["Title"] = "Professional ASP XML Programming";
objDataRow["PublicationDate"] = "2000-05-01";
objDataRow["ImageURL"] = "aspxml.gif";
objDataRow["Precis"] = "As ASP is probably the best server-side coding platform for "
+ "Windows-based systems, it's an obvious choice for use with XML. This book looks "
+ "at all of the XML-related issues you will face when working in this environment.";
objTable.Rows.Add(objDataRow);
objDataRow = objTable.NewRow();
objDataRow["ISBN"] = "1861002882";
objDataRow["Title"] = "Beginning Components for ASP";
objDataRow["PublicationDate"] = "2000-03-01";
objDataRow["ImageURL"] = "components.gif";
objDataRow["Precis"] = "If you use ASP, you're only getting half the power of this "
+ "exciting programming environment if you don't build and use components. This book "
+ "shows you how to get started, with plenty of tips, tricks and useful information.";
objTable.Rows.Add(objDataRow);
// assign the DataTable's DefaultView object to the Repeater control
MyRepeater.DataSource = objTable.DefaultView;
MyRepeater.DataBind(); // and bind (display) the data
}
</script>
<!--------------------------------------------------------------------------->
<!-- #include file="..\global\foot.inc" -->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -