开发者

getting gridview's row's data

I have a gridview which generate a link based on certain condition inside the Grid from code behind. What I want to achieve is when I click on that link, I want to catch all the information from the row that the link is in. So for example, if row 1, 2, and 4 has links in cell 5, When I click row 1's link, I want to get all the cell value from row 1. When I click on row 2's link, I want to get all the cell value from row 2, etc. I am somewhat close but not quite. When I click on row 2, I still get the same value from row 1, same as when I clic开发者_JAVA技巧k on row 4, I get the same value from row 1. Can anyone help? In short, I want to get the row's value based on the link that's in the row. Here's my code:

$('a.SendEmail').click(function(e){
   var Name = $('#<%=GridView2.ClientID%> td:eq(1)').text();
   var Id = $('#<%=GridView2.ClientID%> td:eq(2)').text();
   var DeptName = $('#<%=GridView2.ClientID%> td:eq(3)').text();
   var Total = $('#<%=GridView2.ClientID%> td:eq(4)').text();
});


What you want to do is more like this:

$("a.SendEmail").click(function(e) {
    var row = $(this).parents("tr:first");

    var name= row.children("td:eq(1)").text();
    .
    .
});

Bubble up to the row and then find the children.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜