0
in a repeater, i want to do a function on every item bounded, example
<asp:Repeater runat="server" ID="rptArticleContent"
OnItemDataBound="rptArticleContent_ItemDataBound">
<ItemTemplate>
<tr>
<td width="365" valign="top" align="left" class="bodyContent" bgcolor="#FFFFFF">
<div>
<h2 class="h2">
<asp:Label runat="server" ID="dsds"> <%#Eval("Title") %></asp:Label>
</h2>
<div class="article-body">
<div class="Article-image">
<%#Eval("Image") %>
</div>
<%#Eval("Description") %>
</div>
<asp:Literal runat="server" ID="litArticleSource" Text='<%#Eval("Source") %>'>
</asp:Literal>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
코드 뒤에서 나는 리터럴 내부의 데이터에 대한 조작을 원한다.리피터 데이터 바인딩, 바인드 된 모든 항목의 특정 데이터 조작
protected void rptArticleContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Literal litArticleSource = rptArticleContent.FindControl
("litArticleSource") as Literal;
string ArticleSourcesR = litArticleSource.Text;
}
protected void rptArticleContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Literal litArticleSource = rptArticleContent.FindControl
("litArticleSource") as Literal;
string ArticleSourcesR = litArticleSource.Text;
}
ArticleSourcesR은 여전히 null을 제공하며 일부는 rptArticleContent.FindControl을 사용하여 컨트롤을 잡으면 바운드 된 모든 항목에 적용될 수 있습니다. 그 실마리는 무엇입니까? 무엇을 추가해야합니까?
이전 질문에 대한 답을 살펴보십시오. http://stackoverflow.com/questions/6923871/repeater-databinding-with-manipulation-of-certain-data –