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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:34:15+00:00 2026-06-07T10:34:15+00:00

I have a ListView that creates a table. Each row in the table has

  • 0

I have a ListView that creates a table. Each row in the table has two buttons – Delete and Modify. I’m firing a click event for each button but I’m not sure how to get a handle to the data in the row that the button was clicked.

aspx

<asp:ListView runat="server" ID="usersListView">
    <LayoutTemplate>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>User Name</th>
                    <th>Email</th>
                    <th>Role</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                <asp:PlaceHolder runat="server" ID="groupPlaceHolder"/>
            </tbody>
        </table>
    </LayoutTemplate>
    <GroupTemplate>
        <tr>
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder"/>
        </tr>
    </GroupTemplate>
    <ItemTemplate>
        <td><%# Eval("user.UserName") %></td>
        <td><%# Eval("user.Email") %></td>
        <td><%# Eval("roles") %></td>
        <td>
            <button runat="server" id="modify" class="btn btn-mini" title="Modify" onclick="modify_OnClick">
                <i class="icon-edit"></i>
            </button>&nbsp;
            <button runat="server" id="delete" class="btn btn-mini" title="Delete" onclick="delete_OnClick">
                <i class="icon-trash"></i>
            </button>
        </td>
    </ItemTemplate>
</asp:ListView>

aspx.cs

public void delete_Onclick(object sender, EventArgs e) {

}

public void modify_Onclick(object sender, EventArgs e) {

}
  • 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-07T10:34:16+00:00Added an answer on June 7, 2026 at 10:34 am

    I will try to answer the question in the title since i don’t understand the question itself.

    You can cast the the sender to the Button. The Button’s NamingContainer is the ListViewItem. You can use this to get all your other control in that item by using item.FindControl("OtherControlID").

    For example;

    public void delete_Onclick(object sender, EventArgs e) {
        var btn = (Button)sender;
        var item = (ListViewItem)btn.NamingContainer;
        // find other controls:
        var btnModify = (Button)item.FindControl("modify");
    }
    

    You cannot find text that is not in a server control. But you could use a LiteralControl or Label to display the username or email.

    <td><asp:Label id="Label1" runat="server"
              Text='<%# Eval("user.UserName") %>' />
    </td> 
    

    Now you can use FindControl as shown above to get a reference to the label in codebehind.

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

Sidebar

Related Questions

I have a listview with several items that are created dynamically, each has two
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have ListView that uses a GridView to display several columns of data. Two
I have a ListView in which i have a function that creates images for
I have a ListView that is set up with a MinHeight and a MaxHeight.
I have a ListView that I am populating with items from an ObservableCollection .
A have a ListView that is rendered with multiple items. Now I want to
I have a ListView that is populated using an XML file. However, I want
I have a listview that I'm populating with data and I'm trying to get
I have a listview that is loaded with a list of objects that contain

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.