0
我有一個從數據表最初綁定的gridview。我需要爲gridview中的某一行分配一個相應的id。我怎麼能達到這個目標?另一件事我有一個jQuery代碼通過使用此代碼添加爲GridView另一個細節/行:爲gridview表數據分配id
$('#addBtn').live("click", function() {
var fullname = $("#nameTxt").val();
var username = $("#usernameTxt").val();
var password = $("#passwordTxt").val();
var address = $("#addTxt").val();
var birthdate = $("#birthdatePickerbox").val();
var contactno = $("#contactTxt").val();
var jsonData = JSON.stringify({ fullname: fullname,
username: username,
password: password,
address: address,
birthdate: birthdate,
contactno: contactno
});
$.ajax({
type: "POST",
url: "Admin.aspx/addUser",
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (mydata) {
$.ajax({
url: "Admin.aspx/GetAllUsers",
data: "{}",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (mydata) {
clearAddData();
alert("User successfully added");
for (var i = 0; i < mydata.d.length; i++) {
$("#UserListGrid").append("<tr><td>" + mydata.d[i].userid +
"</td><td>" + mydata.d[i].fullname +
"</td><td>" + mydata.d[i].address +
"</td><td>" + mydata.d[i].birthdate +
"</td><td>" + mydata.d[i].contactno +
"</td><td>" + mydata.d[i].username +
"</td><td>" + mydata.d[i].password +
"</td><td>" + mydata.d[i].usertype + "</td></tr>");
}
$("#tbl").append("</table>");
}
});
},
error: function() {
clearAddData();
alert("Failed to Add user");
}
});
});
這會影響我的ID的初始分配?我需要重新分配表格行的ID與我從數據庫收到的ID。
很好的建議,但我需要在jQuery中完成任務。謝謝! – ljpv14 2012-07-12 15:18:52