Dynamic data in Repeater

Total Post:119

Points:835
 1071  View(s)
Ratings:
Rate this:

in my webpage different users can visit same profile, but users can be either Owner of a profile, or Visitors, and content have to change for those two conditions.

if visitor check profile he see this editor:

<asp:Repeater id="UserLoginRepeater" runat="server">
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
           <asp:Label ID="Label2" runat="server">label Text</asp:Label> <asp:Label runat="server">label text 2</asp:Label>
            </br>
            <asp:Button runat="server" Text="TestButton"/>
            </br>
         <asp:Label ID="Label3" runat="server">Test</asp:Label>   <textarea><%# Eval("Content") %></textarea>
              </br>
              </br>
        </ItemTemplate>
        <FooterTemplate>
        </FooterTemplate>
 </asp:Repeater>

codebehinde:

if User is Owner of a profile TextArea have to be replaced by a label and an other label with textbox have to be added.

What would be the best way to Load controls dynamicly into Repeater?

  1. Post:378

    Points:2694
    Re: Dynamic data in Repeater

    Hi Goti, 


    Use a <asp:ContentPlaceholder> then in your code behind add a handler for the OnItemDataBound event. If you want those controls to handle events, make sure you bind your repeater before OnPreRender for the page.

Answer