Wednesday, 15 July 2015

c# - How to access the data in the button Clicked row in grid(that is dynamically bound by jquery)using javascript? -



c# - How to access the data in the button Clicked row in grid(that is dynamically bound by jquery)using javascript? -

function updategrid(data) { // appending retrieved data(user details) grid var = 0; var content; $("#gridview1").html(''); $("#gridview1").append("<tr><th>" + "name" + "</th><th>" + "gender" + "</th><th>" + "date of birth" + "</th><th>" + "role" + "</th><th>" + "password" + "</th><th>" + "email" + "</th><th>" + "edit" + "</th></tr>"); while (data[i] != null) { $("#gridview1").append("<tr><td>" + data[i].name + "</td><td>" + data[i].gender + "</td><td>" + data[i].dob + "</td><td>" + data[i].role + "</td><td>" + data[i].password + "</td><td>" + data[i].email + "</td><td>" + "<button id=btnedit onclick='test()'>edit</button>" + "</td></tr>");// here m dynamically creating button in last. when click it calls test().how can send info in row test() function in order acces them i++; } } function test() { alert('edit button clicked'); // need access row's info edit button clicked. }

this code. using jquery ajax getting info db , dynamicaaly adding grid, , m creating edit button in end of row. calling method test() on buttonclick. how send values of current row test() funcation or how can access them in test() function...

something that:

$("#gridview1").append("<tr id="+data[i]+"><td>" + data[i].name + "</td><td>" + data[i].gender + "</td><td>" + data[i].dob + "</td><td>" + data[i].role + "</td><td>" + data[i].password + "</td><td>" + data[i].email + "</td><td>" + "<button id=btnedit onclick='test("+data[i].id+")'>edit</button>" + "</td></tr>"); function test(id) { here utilize jquery selector access <tr> id, can operate info in it. }

c# jquery asp.net ajax

No comments:

Post a Comment