I had created html table dynamically like this. Now I want to sort the table based on Name while clicking the Name Header in client side. How can I achieve this?
StringBuilder sb = new StringBuilder();
sb.Append("<table border='1' id='tblCustomers'>");
sb.Append("<tr>");
sb.Append("<th>");
sb.Append("Name");
sb.Append("</th>");
sb.Append("<th>");
sb.Append("City");
sb.Append("</th>");
sb.Append("</tr>");
for(int i=0; i< dtcustomers.count;i++)
{
sb.Append("<tr>");
sb.Append("<td>");
sb.Append(dtcustomers.Rows[i]["Name"]);
sb.Append("</td>");
sb.Append("<td>");
sb.Append(dtcustomers.Rows[i]["City"]);
sb.Append("</td>");
sb.Append("</tr>");
}
sb.Append("</table>");
this.mydiv.InnerHtml = sb.ToString();
Since you are using jQuery and want this done Client Side, you can try this handy plugin.