function updateGrid(data) { // appending the retrieved data(user details) to the grid
var i = 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 I M DYNAMICALLY CREATING A BUTTON IN THE LAST. WHEN I CLICK IT IT CALLS TEST().HOW CAN I SEND THE DATA IN THIS ROW TO THAT TEST() FUNCTION IN ORDER TO ACCES THEM
i++;
}
}
function test() {
alert('edit button is clicked');
// I NEED TO ACCESS THE ROW'S DATA WHERE THIS EDIT BUTTON IS CLICKED.
}
这是我的代码。使用 jquery ajax 我从数据库中获取数据并将动态添加到网格中,并且我还在行的末尾创建了一个编辑按钮。我在 buttonclick 上调用方法 test()。如何将当前行的值发送到该 test() 函数或如何在 test() 函数中访问它们...