S
SushiSean
Hello. I have Repeater and DataSource some table and I need change
row in ItemDataBound event.
So code looks like this
<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "id")%>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataRowView row = e.Item.DataItem as DataRowView;
string id = row["id"].ToString(); //get value here
((DataRowView)e.Item.DataItem)["id"] = 5; //try to change it
}
}
The problem it doesn't have effect. In repeater I see the same id.
So the question is how to change DataItem?
row in ItemDataBound event.
So code looks like this
<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "id")%>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DataRowView row = e.Item.DataItem as DataRowView;
string id = row["id"].ToString(); //get value here
((DataRowView)e.Item.DataItem)["id"] = 5; //try to change it
}
}
The problem it doesn't have effect. In repeater I see the same id.
So the question is how to change DataItem?