多数の行を表示するリピーター オブジェクトがあります。また、リピーターの後に新しいリピーター行を追加できるボタンがあります。問題は、クリック イベントの前に ItemDataBound イベントがトリガーされることです。そのため、ページをリロードすると、通常は表示される最新のアイテムが表示されません。アイテムを表示する唯一の方法は、ページを更新することです。
データ バインドのコード:
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, "');"));
}
}
そしてクリックイベント
protected void SaveOtherStructuress_Click(object sender, EventArgs e)
{
AddOtherStructure();
}
ItemDataBound の前にクリック イベントをトリガーする方法はありますか?