You must Sign In to post a response.
  • Category: [Competition Entries]

    Customize each rows of repeater

    I want to customize each rows of repeater i.e. give different styles and functionality. How can I do it? I searched in net but could not find any resource.

    I've six rows and want to give different css styles to each row. how can I do it? how can I get the id of each row dynamically.

    also the rows with even count should have one text box but not rows with odd counts. how can I do it?

    <asp:Repeater ID="dlComments" Runat="server">

    <ItemTemplate>

    Name: <%# DataBinder.Eval(Container.DataItem, "name") %><br />
    E-mail: <%# DataBinder.Eval(Container.DataItem, "email") %><br />
    Location: <%# DataBinder.Eval(Container.DataItem, "location")%><br/>

    </ItemTemplate>

    <AlternatingItemTemplate>
    Name: <%# DataBinder.Eval(Container.DataItem, "name") %><br />
    E-mail: <%# DataBinder.Eval(Container.DataItem, "email") %><br />
    Location: <%# DataBinder.Eval(Container.DataItem, "location")%><br />
    </AlternatingItemTemplate>

    </asp:Repeater>
  • #688485
    You can customize the individual items (based on datarows) of repeator control with the help of its 'ItemDataBound' event that fires when repeator output is generated (before render).

    As repeator is a container for various UI controls (stick to individual records), we can fetch desired controls and customize its properties (look & feel and data) with following code...

       TextBox address = (TextBox)e.Item.FindControl("txtAddress"));
       address.Text = "Formatted Data";
       address.Property = <any property setting>;
       ...

    Hope this helps.


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.