我有一个gridview:
# | Status | ReturnCode
1 | Imported |
2 | Imported |
3 | Imported |
...应该逐行更新。所以我有一个按钮,当点击时,会将gridview转换为这个,而每一行都在等待更新(由web服务/ pagemethods调用完成):
# | Status | ReturnCode
1 | Pending |
2 | Pending |
3 | Pending |
根据更新的返回值,它应该显示如下所示的逐个更新:
# | Status | ReturnCode
1 | Successful | 1.0.0
2 | Pending | //updating....
3 | Pending |
..所以在所有更新之后,它应该显示为:
# | Status | ReturnCode
1 | Successful | 1.0.0
2 | Successful | 1.0.0
3 | Successful | 1.0.0
..但问题是它显示如下:
# | Status | ReturnCode
1 | Pending |
2 | Pending |
3 | Successful | 1.0.0
我该如何解决这个问题?
供您参考,以下是我的脚本: (由“更新”按钮调用)
<script type="text/javascript">
function updateGrid() {
var grid = document.getElementById("<%=gv.ClientID%>");
for (var i = 0; i < grid.rows.length - 1; i++) {
var statusLabel = grid.rows[i + 1].cells[4].childNodes[1];
statusLabel.innerText = "Pending";
}
updateEachRow(grid);
}
</script>
<script type="text/javascript">
function updateEachRow(grid) {
for (var j = 0; j < grid.rows.length - 1; j++) {
var index = j + 1;
var acctno = grid.rows[index].cells[1].childNodes[1];
var mobile = grid.rows[index].cells[2].childNodes[1];
var operation = grid.rows[index].cells[3].childNodes[1];
var statusLabel = grid.rows[index].cells[4].childNodes[1];
var statCodeLabel = grid.rows[index].cells[5].childNodes[1];
PageMethods.UpdateRow(acctno.innerText, mobile.innerText, operation.innerText, OnResult);
function OnResult(result) {
statusLabel.innerText = (result == "1.0.0" ? "Successful" : "Failed");
statCodeLabel.innerText = result;
}
}
}
</script>
我希望我已经清楚地解释了我的问题。 谢谢你的帮助。 :)