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

  • SEARCH
  • Home
  • 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 8550429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:56:54+00:00 2026-06-11T13:56:54+00:00

Here is the deal, I got a list of documents which is generated by

  • 0

Here is the deal,
I got a list of documents which is generated by the repeater and his databinding. In my markup i got a class for “li” tag when active or not.

What i just need is to set class=”active” on the Li parent tag of my linkbutton when the document is selected.

    <asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate>
            <ul>
        </HeaderTemplate>
        <ItemTemplate>
            <li>
                <asp:LinkButton ID="lnk" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id") %>' OnCommand="Get_carte"><%# Container.FindControl("lnk").ClientID %> <%# DataBinder.Eval(Container.DataItem, "Name") %>  - <%# DataBinder.Eval(Container.DataItem, "id") %> - <%# DataBinder.Eval(Container.DataItem, "compteur") %></asp:LinkButton></li>
        </ItemTemplate> 
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>
  • 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-06-11T13:56:55+00:00Added an answer on June 11, 2026 at 1:56 pm

    I’ve finally found a solution for my issue.

    @Kapil : Your code works but got issue with the reload of the aspx page, then i can’t use this method.

    @Aghilas : I based my solution on your code.

    In fact i can’t use ItemDataBound event because i bind only 1 time my repeater, then i use my OnCommand event on the linkbutton. Here is my aspx code:

        <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Rpt_DataBound">
                    <HeaderTemplate>
                        <ul>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <li runat="server" ID="li">
                            <asp:LinkButton ID="lnk" class="linkButton" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Id") %>' OnCommand="Get_carte"><%# Container.FindControl("lnk").ClientID %> <%# DataBinder.Eval(Container.DataItem, "Name") %>  - <%# DataBinder.Eval(Container.DataItem, "id") %> - <%# DataBinder.Eval(Container.DataItem, "compteur") %></asp:LinkButton></li>
                    </ItemTemplate> 
                    <FooterTemplate>
                        </ul>
                    </FooterTemplate>
                </asp:Repeater>
    

    And my GetCarte Method:

        protected void Get_carte(object sender, CommandEventArgs e)
        {
            LinkButton lnk = (LinkButton)sender;
            ViewState["liactive"] = lnk.UniqueID.ToString().Substring(0, lnk.UniqueID.ToString().Length - 4);
            lbl_carte.Text = lnk.UniqueID + " " + e.CommandArgument.ToString();
            foreach (RepeaterItem rI in Repeater1.Items)
            {
                if (rI.ItemType == ListItemType.Item || rI.ItemType == ListItemType.AlternatingItem)
                {
                    string liactiv = "";
                    if (ViewState["liactive"] != null)
                        liactiv = ViewState["liactive"].ToString();
                    var li = (HtmlControl)rI.FindControl("li");
                    if (li.UniqueID.ToString().Substring(0, li.UniqueID.ToString().Length - 3) == liactiv) //Adjust your condition
                        li.Attributes.Add("class", "active");
                    else
                        li.Attributes.Remove("class");
                }
            }
    
        }
    

    Thanks for your help.

    PS: I put ID in ViewState in case of needing the value in another part of my code. I also can replace my substring by lastindexof method.

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

Sidebar

Related Questions

So here's the deal. I've got my solution which has a few projects in
Here's the deal. I've got articles and issues, both of which can have a
Ok here's the deal I got one table with a bunch of client information.
Hey all, here's the deal... I've got a UIImage that is being loaded in
Here's the deal. I've got a program that will load a given assembly, parse
So here's the deal: I've got a JPanel and a JTextArea inside that one.
Alright here's the deal, I'm taking an intro to C++ class at my university
Here's the deal: I got two db models, let's say ShoppingCart and Order .
Here's the deal. I've got cygwin installed in Win7 envionment. This is the sequence
So here's the deal... I've got to silence the user's phone when they have

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.