C# 中继器中的成员配置文件
前端C# 中继器中的成员配置文件,c#,asp.net,membership,backend,profiles,C#,Asp.net,Membership,Backend,Profiles,前端 <asp:Repeater ID="rpt_comments" runat="server" DataSourceID="sqldata_rpt_comments" OnLoad="rpt_comments_Load"> <ItemTemplate> <div class="comments"> <div class="news-comment-left"> <asp:Image ID="im
<asp:Repeater ID="rpt_comments" runat="server" DataSourceID="sqldata_rpt_comments" OnLoad="rpt_comments_Load">
<ItemTemplate>
<div class="comments">
<div class="news-comment-left">
<asp:Image ID="imgCommentAvatar" Width="50px" Height="50px" runat="server" />
</div>
<div class="news-comment-right">
<asp:Label ID="lblCommentProfile" runat="server"></asp:Label>
<asp:Label ID="lblCommentAuthor" runat="server" Text='<%#Eval ("CommentsAuthor") %>' Visible="false"></asp:Label>
<div style="float: right;"><%#Eval ("CommentsDate", "{0:dd.MM.yyyy}") %></div>
<br />
<%#Eval ("Comment") %><br />
</div>
<br />
<br />
<br />
<br />
</div>
</ItemTemplate>
</asp:Repeater>
如您所见,我正在尝试使用
FindControlRecursive
检索中继器中的控件,当我提取控件并想知道其中的内容时,我在asp.net成员身份中获得了配置文件,它也可以工作,但仅适用于中继器中的1个重复项,因此我需要帮助如何编码,以便它不断重复配置文件对于每个CommentAuthor
都有。使用Repeater.ItemDataBound事件
public void commentsprofiles()
{
Label CommentAuthor = (Label)Tools.FindControlRecursive(rpt_comments, "lblCommentAuthor");
Label CommentProfile = (Label)Tools.FindControlRecursive(rpt_comments, "lblCommentProfile");
Image imgCommentAvatar = (Image)Tools.FindControlRecursive(rpt_comments, "imgCommentAvatar");
ProfileCommon userProfile = Profile.GetProfile(CommentAuthor.Text);
imgCommentAvatar.ImageUrl = userProfile.Avatar;
CommentProfile.Text = userProfile.NickName;
}
protected void rpt_comments_Load(object sender, EventArgs e)
{
commentsprofiles();
}