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 610891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:43:29+00:00 2026-05-13T17:43:29+00:00

Basically what i am trying to do is display a list of categories. And

  • 0

Basically what i am trying to do is display a list of categories. And if the admin is logged in
i want to show some buttons next to each category. For example a button to delete it. The problem is that i dont know how to pass a parameter to the function that does the action.

Like i specify that on button click the function ‘DeleteCat’ must be called but if i cant pass the ID of the category to be deleted this wont work.

I know this can be done with commands and a repeater, but its not an option, i cant use a repeater.

So apparanly this is what i am aiming for:

But of course it does not work.

    <%For Each Cat In Category.Children%>
        <p class="SubCategory">
            <%=Cat.Name%> 

            <%If User.Identity.Name = "Admin" Then%>
                <asp:LinkButton ID="LinkButton6" runat="server" OnClick="AddItem" Text="A+" CommandArgument=<%=Cat.ID %> />
            <%End If%>
        </p>
    <%Next %>
  • 1 1 Answer
  • 1 View
  • 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-13T17:43:29+00:00Added an answer on May 13, 2026 at 5:43 pm

    Your event handler AddItem should be able to evaluate the sender of the event and the CommandEventArgs

    void AddItem(Object sender, EventArgs e)
    {
        int result;
        bool returnValue;
    
        Button clickedButton = (Button)sender;
        returnValue = Int32.TryParse(clickedButton.CommandArgument, result);
    
        // then other stuff happens ...
    }
    

    See detailed example here.

    edit

    Completed code sample as suggested by Brandon.


    Alternative solution, using a CheckBoxList

        ...
        <script language="C#" runat="server">
            void Page_Load(Object Sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    // bind data to controls
                    this.itemRepeater.DataSource = Category.Children;
                    this.adminList.DataSource = Category.Children;
                    this.itemRepeater.DataBind();
                    this.adminList.DataBind();
                }
    
                // set visibility according to user
                this.itemRepeater.Visible = (User.Identity.Name != "Admin");
                this.adminList.Visible = (User.Identity.Name == "Admin");
                this.adminButton.Visible = (User.Identity.Name == "Admin");
            }
    
            protected void AddItem(object sender, EventArgs e)
            {
                foreach(ListItem currentitem in this.adminList.Items)
                {
                    if(currentitem.Selected)
                    {
                        // do something with the selected value
                        int i;
                        bool isparsed = Int32.TryParse(currentitem.value, i);
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="mainForm" runat="server">
            <asp:Repeater ID="itemRepeater" runat="server">
                <ItemTemplate>
                    <p><%# DataBinder.Eval(Container.DataItem, "value") %></p>
                </ItemTemplate>
            </asp:Repeater>
            <asp:CheckBoxList ID="adminList" runat="server" />
            <br />
            <asp:Button ID="adminButton" OnClick="AddItem" runat="server" Text="Add seleted Items" />
        </form>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display a list of projects using backbone.js. Basically, backbone should be
So basically what I am trying to do is retrieving a list of categories
gcc 4.4.3 c89 I am trying to display the address. Basically, I just want
I am basically trying to create a display object transformation manager which will allow
What I am trying to do is create ideally a nested List basically a
I'm trying to build a TreeView in WPF that has categories. Basically the structure
I'm using CommonsGuy's drag n drop example and I am basically trying to integrate
I'm trying to display some cards into a QListView but I'm really having trouble
Im trying to display all the folders that are in a specific directory. Basically
I am trying to build a simple horizontal list, where each list item is

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.