0

前端

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

后端

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

如您所见,我正在尝试通过使用检索转发器FindControlRecursive中的控件,当我提取控件并想告诉它们中的内容时,我在 asp.net Membership 中获得了配置文件,它也有效,但仅适用于 1在我的转发器中重复项目,所以我需要帮助如何编码,以便它不断重复每个CommentAuthor存在的配置文件。

4

1 回答 1

1

使用 Repeater.ItemDataBound 事件

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

于 2012-10-26T14:45:17.013 回答