0
私はプロジェクトで作業していて、編集可能なデータを表示するためにgridviewを使用しています。私はこのデータにいくつかの制約があり、データがデータベースに送られる前にフロントエンドチェックを実行したいと思います。javascriptのgridviewで新しい入力値を取得する方法
<asp:Button ID="Update" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" onclientClick="check(this)"/>
そして、次のように私のJavaScriptは次のとおりです:次のように私のコードがある
function check(up) {
var ip, desc, rt;
var table = document.getElementById('<%=GridView1.ClientID %>');
var row = up.parentNode.parentNode;
ip = row.cells[1].children[0].attributes[2].value;
desc = row.cells[2].children[0].attributes[2].value;
rt = row.cells[3].children[0].attributes[2].value;
time = parseFloat(rt);
alert(rt);
if (ip === null || ip.match(/^ *$/) !== null) {
alert('please enter IP Address');
return false;
}
else if (desc === null || desc.match(/^ *$/) !== null) {
alert('please enter description');
return false;
}
else if (rt === null || rt.match(/^ *$/) !== null) {
alert('please enter refresh time');
return false;
}
else if (isNaN(time)){
alert('refresh time must be a number');
return false;
}
else if (Number(time) < 1) {
alert('the minimum refresh time is 1');
return false;
}
else
return true;
}
問題は、私はいつも古い値ではない新しいものを得ることです。 JavaScriptで新しい値を取得するにはどうすればよいですか? 私は私の更新クエリでsqlDataSource
を使用しています:
UPDATE Clients
SET ipAddress = @ipAddress, description = @description, refreshTime = @refreshTime
WHERE machineName = @MachineName