在转发器设计中,我有类似的东西:
Text='<%# Eval("deposit") %>'
如何将代码隐藏中的值插入“存放”而不是使用dataSource,而是通过手动插入字符串值?
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="lblDeposit" runat="server" Text='<%# Eval("deposit") %>' />
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:0)
您可以使用ItemDataBound事件手动绑定字段值。像:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
Label lbl = e.Item.FindControl("lblDeposit") as Label;
lbl.Text = "You Manual String Value";
}
}
将此事件附加到html标记中的转发器:
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">