zSynopsis
zSynopsis

Reputation: 4854

Selectable Table Row Jquery Asp.net

I would like to create a table where the rows are selectable via jquery. I'd also like to pass certain table cell values from a double click event on a row to another page.

Does any one have examples of how this would work?

Upvotes: 3

Views: 4892

Answers (1)

hunter
hunter

Reputation: 63522

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();
   });

});

Upvotes: 2

Related Questions