나는 단순히 ItemDataBound Event
을 처리하고 현재 수행해야 할 작업을 모두 RepeaterItem
으로 수정했습니다.
예 :
private void Repeater1_ItemDataBound(object Sender, RepeaterItemEventArgs e)
{
// Make sure you filter for the item you are after
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
PlaceHolder listLocation = (PlaceHolder)e.Item.FindControl("listPlaceHolder");
var subItems = ((MyClass)e.Item.DataItem).SubItems;
listLocation.Controls.Add(new LiteralControl("<ul>");
foreach(var item in subItems)
{
listLocation.Controls.Add(new LiteralControl("<li>" + item + "</li>"));
}
listLocation.Controls.Add(new LiteralControl("</ul>");
}
}
내가 복합 컨트롤 내에서이 작업을 수행 할 수 있을까? –
아담이 당신의 혼란이 어디 있는지 모르겠습니다. 아마도 질문을 편집하고 코드 또는 추가 설명을 추가 할 수 있습니다. –