可选表行Jquery Asp.net

时间:2009-03-16 22:16:24

标签: jquery asp.net select

我想创建一个表,可以通过jquery选择行。 我还想将某个表单元格值从一行上的双击事件传递到另一个页面。

是否有人举例说明这是如何运作的?

1 个答案:

答案 0 :(得分:2)

var selected = null;

$(document).ready(function(){
   $("#<%=myTable.ClientID %>").find("tr").click(function(){
      $(selected).removeClass("selected");
      $(this).addClass("selected");
      selected = this;
   });

   $("#<%=myTable.ClientID %>").find("tr").dblclick(function(){

      /* if you just want to dig into that record I would put a custom attribute on the row */
      window.location = "<%=ResolveUrl("~/one/folder/deeper/") %>?record=" + $(this).attr("RecordId");

      /* or you could have a hidden LinkButton in the row (Text="" or not set) that you could trigger. Make sure you set the CommandName="Something" and CommandArgument="RecordId" */
      $(this).find("a").click();
   });

});