Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3355998
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:27:44+00:00 2026-05-18T02:27:44+00:00

I am using nested repeaters. I render several groups and every group has members

  • 0

I am using nested repeaters. I render several groups and every group has members that I need to render out different properties to.

I am using ItemDataBound on the nested repeater to find out which member the nested repeater is rendering out at the moment. I have <% %> tags in the .aspx which checks if the current user has a certain property, and if it has, I render the divs and other HTML elements that need to go there.

All the data is correct. When I debug I collect the correct data and I get the right info about who the user is and what properties the user has. I save the current evaluated user in a protected string currentRenderedUser that I use to find out who the user is in the aspx file.

The problem is that by the time the <% %> on the aspx gets evaluated the repeater has already gone through all the sets or something, because the currentRenderedUser is the same during every evalutaion in the aspx file.

I don’t know the correct terminology for “<% %>” code in the aspx file, sorry.

This is the relevant parts of the aspx (I think):

<ItemTemplate>
    <!-- nested repeater data -->

    <tr>
        <td width="50%"><div class="memberName"><%# DataBinder.Eval(Container.DataItem, "userEmail" )%></div></td>


        <div style="display: none;"></div>
        <% if (CheckIfUserIsAdmin(email, currentRenderedGroup))
                    {  %>

                   <%if (CheckIfUserIsAdmin(currentRenderedUser, currentRenderedGroup))
                     { //Checks so that the user being rendered isn't already admin%>
                          <td><div style="margin-right:30px;" class="makeAdminButton"></div></td>
                    <% }
                     else
                     {%>
                        <td><div style="margin-right:30px;" class="makeAdminButton"><asp:ImageButton ID="ImageButtonMakeUserAdmin" CommandName="MakeAdmin" BorderWidth="0" ImageUrl="~/gfx/doAdmin.png" CommandArgument='<%#Convert.ToString(DataBinder.Eval(Container.DataItem, "userEmail" )) + " " +  Convert.ToString(DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "groupId"))%>' runat="server" AlternateText="Make admin" /></div></td>
                        <td><div class="removeUserButton"><asp:ImageButton ID="ImageButtonRemoveUserFromGroup" CommandName="RemoveUserFromGroup" BorderWidth="0" ImageUrl="~/gfx/can.png" CommandArgument='<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "userEmail" )) + " " + Convert.ToString(DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "groupId"))%>' runat="server" AlternateText="Delete" /></div></td>
                                <% } %>
       <%}%>

    </tr>


</ItemTemplate>

And this is the part of the back-end that evaluates the current user:

protected void NesterRepeater_ItemDataBound(object sender,
                       System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.AlternatingItem
        || e.Item.ItemType == ListItemType.Item)
       {
           DataRowView dataRowView = (DataRowView)e.Item.DataItem;

           string memberInGroup = Convert.ToString(dataRowView["userEmail"]);
           currentRenderedUser = memberInGroup;
       }
}

How can I solve this in a better (or atleast, working) way?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:27:44+00:00Added an answer on May 18, 2026 at 2:27 am

    The problem is that the event ItemDataBound is executed first so you probably always get the value of the last record from the Repeater’s DataSource if I’m not mistaken.

    It is better to do it this way:

    <ItemTemplate>
        <tr>
            <td width="50%"><div class="memberName"><%# DataBinder.Eval(Container.DataItem, "userEmail" )%></div></td>
            <div style="display: none;"></div>
            <asp:PlaceHolder ID="phNoAdmin" runat="server" Visible="false">
                <td><div style="margin-right:30px;" class="makeAdminButton"></div></td>
            </asp:PlaceHolder>
    
            <asp:PlaceHolder ID="phAdmin" runat="server" Visible="false">
                <td><div style="margin-right:30px;" class="makeAdminButton"><asp:ImageButton ID="ImageButtonMakeUserAdmin" CommandName="MakeAdmin" BorderWidth="0" ImageUrl="~/gfx/doAdmin.png" CommandArgument='<%#Convert.ToString(DataBinder.Eval(Container.DataItem, "userEmail" )) + " " +  Convert.ToString(DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "groupId"))%>' runat="server" AlternateText="Make admin" /></div></td>
                <td><div class="removeUserButton"><asp:ImageButton ID="ImageButtonRemoveUserFromGroup" CommandName="RemoveUserFromGroup" BorderWidth="0" ImageUrl="~/gfx/can.png" CommandArgument='<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "userEmail" )) + " " + Convert.ToString(DataBinder.Eval(((RepeaterItem)Container.Parent.Parent).DataItem, "groupId"))%>' runat="server" AlternateText="Delete" /></div></td>
            </asp:PlaceHolder>
        </tr>
    </ItemTemplate>
    

    And the code behind:

    protected void NesterRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            DataRowView dataRowView = (DataRowView)e.Item.DataItem;
    
            PlaceHolder phNoAdmin = e.Item.FindControl("phNoAdmin") as PlaceHolder;
            PlaceHolder phAdmin = e.Item.FindControl("phAdmin") as PlaceHolder;
    
            string memberInGroup = Convert.ToString(dataRowView["userEmail"]);
            currentRenderedUser = memberInGroup;
    
            if (CheckIfUserIsAdmin(email, currentRenderedGroup))
            { 
                if (CheckIfUserIsAdmin(currentRenderedUser, currentRenderedGroup))
                {
                    phNoAdmin.Visible = true;
                    phAdmin.Visible = false;
                }
                else
                {
                    phNoAdmin.Visible = false;
                    phAdmin.Visible = true;
                }
            }            
        }
    }
    

    It would be better if you bind the data inside the 2 PlaceHolder control I wrote also in code behind for maintainability reason.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I am using this to export a repeater (with multiple nested repeaters)
I am using Spring Forms for my web application. For nested properties, the form
I am using nested repeaters to build a table for reasons I won't discuss
I am trying to create nested repeaters dynamically using ITemplate. This repeater is like
What are the pros and cons of using nested public C++ classes and enumerations?
It is often useful to implement algorithms using nested array operations. For example, to
I am using some nested layouts in Ruby on Rails, and in one of
How would I create a nested grouping for the table below, using LINQ? I
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.