I have a repeater object that displays a number of rows. I also have a button after the repeater which allows a new repeater row to be added. The issue it that the ItemDataBound event is getting triggered before the click event. So when the page reloads it does not have the newest item that would normally show up. The only way to see the item is to refresh the page.
Code for data bound:
protected void default_ItemDataBound(object source, RepeaterItemEventArgs e)
{
// Bind the controls
if (e.Item.ItemType == ListItemType.AlternatingItem
|| e.Item.ItemType == ListItemType.EditItem
|| e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.SelectedItem)
{
XElement otherStructureElement = XML.XPathSelectElement(e.Item.DataItem.ToString());
HtmlAnchor lnkRemove = e.Item.FindControl("lnkRemoveForm") as HtmlAnchor;
if (lnkRemove != null && otherStructureElement != null)
lnkRemove.Attributes.Add("onclick", string.Concat("return deleteOtherStructure('",otherStructureElement.Attribute("id").Value, "');"));
}
}
and the click event
protected void SaveOtherStructuress_Click(object sender, EventArgs e)
{
AddOtherStructure();
}
Is there a way to trigger the click event before the ItemDataBound?