%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Repeater.Default" %>
!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">
div>
asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="Repeater.DataSetEmployeesTableAdapters.CategoriesTableAdapter">
/asp:ObjectDataSource>
asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1"
onitemdatabound="Repeater1_ItemDataBound"
onitemcreated="Repeater1_ItemCreated">
HeaderTemplate>
类别表
table border="1">th>类别ID/th>th>类别名称/th>th>描述/th>th>图片/th>
/HeaderTemplate>
ItemTemplate>
tr>
td>%#Eval("CategoryID")%>/td>
td>
asp:TextBox ID="TextBox1" runat="server" Text='%#Eval("CategoryName")%>'>/asp:TextBox>
/td>
td>%#Eval("Description")%>/td>
td>img alt="None" src='%#Eval("Picture")%>' />/td>
/tr>
/ItemTemplate>
AlternatingItemTemplate>
tr>
td style="background-color:Blue">%#Eval("CategoryID")%>/td>
td style="background-color:Blue">
asp:TextBox ID="TextBox1" runat="server" Text='%#Eval("CategoryName")%>'>/asp:TextBox>
/td>
td style="background-color:Blue">%#Eval("Description")%>/td>
td style="background-color:Blue">img alt="None" src='%#Eval("Picture")%>' />/td>
/tr>
/AlternatingItemTemplate>
FooterTemplate>
/table>
/FooterTemplate>
/asp:Repeater>
/div>
/form>
/body>
/html>
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox tb = (TextBox)e.Item.FindControl("TextBox1");
if (tb.Text.Contains("o"))
{
tb.BackColor = Color.Red;
}
}
}