I've been investigating a few different ways to achieve this. The current one trying to use jquery.

//Find each edit link
var chks = $('#ContentPlaceHolder1_GVJobList').find('a');
//For each edit link bind click with function
$.each(chks, function () { $(this).on('click', function () {
    // trying to get the calling element
    var $self = $(this);
    // trying to get the parent(cell) then parent(row) then find the checkbox
    alert($($self).parent().parent().find('input:checkbox').val());
}) });

It's been a problem for a while so any help would be greatly appreciated. I am open to using any method that would achieve this.

<asp:GridView ID="GVJobList" runat="server" AutoGenerateColumns="False" DataSourceID="SDSJobsDetails" OnRowCommand="GV_JobList_RowCommand" DataKeyNames="InvoiceID">
        <Columns>
            <asp:TemplateField HeaderText="Parts/Services">
                <ItemTemplate>
                    <asp:Button ID="B_EditJob" runat="server" CommandName="EditJob" Text="update" CommandArgument='<%# Bind("InvoiceID") %>' CausesValidation="False" UseSubmitBehavior="False" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="InvoiceID" HeaderText="InvoiceID" InsertVisible="False" ReadOnly="True" SortExpression="InvoiceID" />
            <asp:BoundField DataField="FK_CustomerID" HeaderText="FK_CustomerID" SortExpression="FK_CustomerID" />
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
            <asp:BoundField DataField="TotalCostExGST" HeaderText="TotalCostExGST" SortExpression="TotalCostExGST" />
            <asp:BoundField DataField="TotalGST" HeaderText="TotalGST" SortExpression="TotalGST" />
            <asp:BoundField DataField="TotalCost" HeaderText="TotalCost" SortExpression="TotalCost" />
            <asp:BoundField DataField="AmountPaid" HeaderText="AmountPaid" SortExpression="AmountPaid" />
            <asp:BoundField DataField="Date_Booked" HeaderText="Date_Booked" SortExpression="Date_Booked" />
            <asp:BoundField DataField="Date_Time_Scheduled" HeaderText="Date_Time_Scheduled" SortExpression="Date_Time_Scheduled" />
            <asp:BoundField DataField="Date_Completed" HeaderText="Date_Completed" SortExpression="Date_Completed" />
            <asp:BoundField DataField="Date_Paid" HeaderText="Date_Paid" SortExpression="Date_Paid" />
            <asp:CheckBoxField DataField="completed" HeaderText="completed" SortExpression="completed" />
            <asp:CheckBoxField DataField="PaidInFull" HeaderText="PaidInFull" SortExpression="PaidInFull" />
            <asp:CheckBoxField DataField="PartPaid" HeaderText="PartPaid" SortExpression="PartPaid" />
            <asp:TemplateField HeaderText="Invoice">
                <ItemTemplate>
                    <asp:Button ID="B_CreateInvoice" runat="server" CommandName="CreateInvoice" Text="Create Invoice" CommandArgument='<%# Bind("InvoiceID") %>'  CausesValidation="False" UseSubmitBehavior="False" />
                    <asp:Button ID="B_ViewInvoice" runat="server" CommandName="ViewInvoice" Text="View Invoice" CommandArgument='<%# Bind("InvoiceID") %>'  CausesValidation="False" UseSubmitBehavior="False" />
                    <asp:Button ID="B_SendInvoice" runat="server" CommandName="SendInvoice" Text="eMail Invoice" CommandArgument='<%# Bind("InvoiceID") %>'  CausesValidation="False" UseSubmitBehavior="False" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

Related posts

Recent Viewed