zSynopsis zSynopsis - 2 months ago 24
ASP.NET (C#) Question

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?

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

});
Comments