HtmlCode
<asp:Repeater runat="server" ID="rptList" OnItemDataBound="rptList_ItemDataBound">
<HeaderTemplate>
<tr>
<td ><asp:Label ID="lblHead" runat="server" Text="Label"></asp:Label></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="board_text04" style="display:none;">
<asp:Label ID="lblContent" runat="server" Text="Label"/>
</td>
</tr>
</ItemTemplate>
Cs단 - 일반함수안에서
public void InitUserControl()
{
// 헤더 접근
Label lblHead = (Label)rptList.Controls[0].FindControl("lblHead");
// Item 접근
foreach (RepeaterItem Item in rptList.Items)
{
Label lblContent = (Label)Item.FindControl("lblContent");
}
}
Cs단 - DateBound함수안에서
protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{// Item 접근
Label lblContent = (Label)Item.FindControl("lblContent");
}
else if (e.Item.ItemType == ListItemType.Header)
{// 헤더 접근
Label lblHead = (Label)Item.FindControl("lblHead ");
}
}
댓글 없음:
댓글 쓰기