我需要在使用jquery的ajax调用中传递一个GridView DataKey (主键)作为参数。
但是,我没有在源代码HTML.I中公开我的主键列。我已经尝试隐藏表的TD (第一列),但它没有隐藏在源代码中。
下面是Jquery代码:
$(function(){
$("tr").each(function(){//hide primary key columns in design
$("td:first",this).hide();
$("th:first",this).hide();
});
$("tr:not(:first)").click(function(){
$.ajax({
type:"POST",
url:"CRUDWeb.asmx/DeleteRow",
data:"{'duviID': '" + $(this).children("td:first").html() + "'}",//get primary key
contentType:"application/json; charset=utf-8",
dataType:"json",
success:function(){},
error:function(rh){alert(rh.responseText);}
});
});
});
有什么想法吗?
发布于 2010-02-10 01:19:41
你不能这么做。
主键必须打印在源代码中的某个位置,否则jquery (客户端)无法将信息发送给ajax调用。
唯一的解决方案是,如果您可以在源代码中打印另一个唯一键,那么您可以将此键发送到脚本并查找主键。
https://stackoverflow.com/questions/2230897
复制相似问题