repeater数据绑定控件,主要是用来进行数据展示的,帮定一个数据源objectdatasource就可以了
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataRowView rowView = (DataRowView)e.Item.DataItem;
var personRow =( Repeater数据绑定事件.Repeater.DAL.DataSet1.mytableRow )rowView.Row;
if (personRow.age>30)
{
TextBox txtage = (TextBox)e.Item.FindControl("TextBox1");
txtage.BackColor = Color.Red;
}
}
aspx里进行repeater展示:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1"
onitemdatabound="Repeater1_ItemDataBound">
<ItemTemplate><%#Eval("username") %><asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("age")%>'></asp:TextBox></ItemTemplate>
</asp:Repeater> |