Asp net grid view使用jquery选择行
我在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; });