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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:37:59+00:00 2026-05-12T19:37:59+00:00

The code behind file creates a list of employees and the asp.net page loops

  • 0

The code behind file creates a list of employees and the asp.net page loops through list.
Now, How do I assign the employeedID to the commandArgument of an asp:button?

  <%foreach(var employee in employeesList){%>
    <tr>
     <td><%=employee.firstName%></td>
     <td><%=employee.lastName%></td>
    /*How to access employee.Id in the commandArgument? */
    <td><asp:Button ID="btnDeleteEmployee" runat="server" CommandArgument=''    Text="Delete" OnCommand="btnDeleteEmployee_Click" /></td>
    </tr>
<%}%>
  • 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-12T19:37:59+00:00Added an answer on May 12, 2026 at 7:37 pm

    Based on your comments, here is a nested example:

    Markup:

    <asp:Repeater runat="server" ID="rptOutter" 
        onitemdatabound="rptOutter_ItemDataBound" >
        <ItemTemplate>
            <tr>
                <td><%#Eval("firstName") %></td>
                <td><%#Eval("lastName") %></td>
                <td><asp:Button runat="server" ID="btnDeleteEmployee" CommandArgument='<%#Eval("Id") %>' Text="Delete" OnCommand="btnDeleteEmployee_Click"  /></td>
                <td>
                    <asp:Repeater runat="server" ID="rptInner" >
                        <ItemTemplate>
                            <table>                                
                                <tr>
                                    <td><%#Eval("firstNameInner") %></td>
                                    <td><%#Eval("lastNameInner") %></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:Repeater>
    
                </td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>
    

    CodeBehind:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            rptOutter.DataSource = outterDataSource;
            rptOutter.DataBind();
        }
    
    }
    
    protected void rptOutter_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RepeaterItem item = e.Item;
        if ((item.ItemType == ListItemType.Item) ||
            (item.ItemType == ListItemType.AlternatingItem))
        {
            //get your datasource from parent repeater if needed
            //cast to your datasource type
            //DataSourceObject ds = (DataSourceObject)item.DataItem;
            Repeater r = e.Item.FindControl("rptInner") as Repeater;
            if (r != null)
            {
                r.DataSource = innerDataSource;
                r.DataBind();
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a code segment on an asp.net page in the code-behind file. I
I created a WebMethod in the code-behind file of my page as such: [System.Web.Services.WebMethod()]
I created a global.asax file for an asp.net application. I run some code in
I moved a silverlight file (xaml) to a different project, and now code behind
I inserted an ASP.NET check box list control inside an AJAX tab container. Now
I'm trying to create datagrid tooltip entirely in code behind file. Tooltip XAML code
I have a Xaml file that does not have any code behind. I would
I have a executable jar file and i want to see code behind it.
i want to add file(photo) to fileupload control in the c#(code behind) thanks
Code Behind: [WebMethod] public static string emp() { return BlaBla; } Aspx Page: $(document).ready(function()

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.