我在 asp.net 网页上有一个普通的 gridview...我想使用 jquery 选择一行,然后按一个按钮将 id 和 descripcion 列发送到 Web 服务...
我的问题是如何选择行并获取我想要的信息...全部使用 jquery。
最佳答案
尝试类似的事情
$('#<%=Grid.ClientID %>').delegate('tr', 'click', function(){
$('#<%=Grid.ClientID %> tr').not(this).removeClass('selectedRow');
$(this).toggleClass('selectedRow');
});
这应该使您能够在单击时选择单个 GridView 行。
之后,对于按钮控件,使用以下内容
$('#<%=Btn.ClientID %>').click(function(){
alert($('#<%=Grid.ClientID %>').find('tr.selectedRow').html());
// code to call the webservice using columns from $('#<%=Grid.ClientID %>').find('tr.selectedRow')
// prevent Button control from causing a postback
return false;
});
关于jquery - Asp Net GridView 使用 jquery 选择行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9355889/