There is such code in asp.net webforms:

<asp:GridView ID="grdRole" runat="server" AutoGenerateColumns="false" CssClass="NormalText" Width="100%" OnRowDataBound="grdRole_OnRowDataBound"> <RowStyle HorizontalAlign="Center" CssClass="NormalText"/> <HeaderStyle BackColor="#fb9d00" CssClass="BlackHeader"/> <Columns> <asp:BoundField DataField="UserName" ReadOnly="true" HeaderText="User Name" /> <asp:BoundField DataField="FirstName" ReadOnly="true" HeaderText="First Name" /> <asp:BoundField DataField="LastName" ReadOnly="true" HeaderText="Last Name" /> <asp:BoundField DataField="CreatedOn" ReadOnly="true" HeaderText="Created on"/> <asp:BoundField DataField="Name" HeaderText="Role"/> <asp:ButtonField ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center" ControlStyle-CssClass="Button" CommandName="BindUserFields" Text="Edit" HeaderText="" ButtonType="Link" CausesValidation="False"/> 

That is, some kind of gridview makes a table with an edit button. You need to somehow get through jquery the values ​​of all the cells of the row in the table where this button is located. That is, the essence is that when I click on the edit button, I get a popup, with fields that need to be filled with data from the cells of the line in which the button was pressed. How can I do that ? I tried through parent, but nothing happened.

    1 answer 1

    Are you interested in this feature?

     $('table button').click(function(e) { var tds = $(this).parent('td').siblings('td'); var row = []; $.each(tds, function(i, c) { row.push($(c).text()); }); $('#result').text(row.join(' ')); }); 
     table { border-collapse: collapse; } table td { border: 1px solid black; padding: 5px; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tr> <td>r1c1</td> <td>r1c2</td> <td> <button>Click me</button> </td> </tr> <tr> <td>r2c1</td> <td>r2c2</td> <td> <button>Click me</button> </td> </tr> <tr> <td>r3c1</td> <td>r3c2</td> <td> <button>Click me</button> </td> </tr> </table> <div id="result"></div>