0

Frontend

<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>

Backend

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();
}

As you can see I'm trying to retrieve the controls in my repeater by using FindControlRecursive and when I've extracted the controls and want to tell whats in them I get the profiles in asp.net Membership and it also works but only for the 1 repeating item in my repeater so I need help how to code so it keeps repeating the profiles for each CommentAuthor there is.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
user1497360
  • 37
  • 1
  • 5

1 Answers1

1

Use the Repeater.ItemDataBound Event

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

Joe
  • 1,649
  • 12
  • 10