0

I have a c# Grdiview, which contains an Hyperlink in the first col. when the user clicks the link, I need the following to happen.

1) Obtain the DataKey Name of the row selected and pass this to a method (code behind), which will build the neccessary data to show in the Model.

2) Present the Model with the data built.

So, I have the Model working, in the sense that I can present a empty one, but I know need assistance with the rest.

I have the following function which doesn't display the value I need

    $(function () {
        $('.view-details').click(function (e) {
            e.preventDefault();
            $('#myModal').modal();
            $('#ticket-id').text("Ticket id: " + $(this).children('td').eq(0).text());
        });
        $('#ticket-tabs a').click(function (e) {
            e.preventDefault();
            $(this).tab('show');
        })
        $('#ticket-tabs a:first').tab('show');
    });

 EDIT  <Columns> 
            <asp:TemplateField>
                      <ItemTemplate>
                          <asp:Hyperlink href="#" data-id="1" class="view-details" runat="server">View details</asp:Hyperlink></td>
                      </ItemTemplate>
                  </asp:TemplateField>     
             <asp:TemplateField HeaderText="Message Id">

         .
         .
        </Columns>

Once I have the Id, I can then progress trying to populate the data to display

4

1 回答 1

0

最终使用这种方法得到了我需要的 DataKeyName 。

 $('#ticket-id').text("Ticket id: " + $(this).closest('tr').children().eq(1).html());

这只是获取第二个值 'eq(1)',它是 Id,但显示在表中。

于 2013-07-08T18:34:00.360 回答