Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
Re:I have table i want sorting for the columns but i tried and included some sorting plugin also.still it is throwing some errors.
in error console.
for same thing i want edit the records based on record(row) and delete the records based on record(row).
Timestamp: 10/9/2012 5:54:10 PM
Error: TypeError: $("#tbDetails").tablesorter is not a function
Source File: http://localhost:50976/User.aspx
Line: 52
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="User.aspx.cs" Inherits="FiSoftCustomerPortal.User" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

    <%--<script type="text/javascript" src="Scripts/Jquery.min2.js"></script>     --%>
    <%--<script src="Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>--%>
    <script src="Scripts/jquery-latest.js" type="text/javascript"></script>
    
    <script src="Scripts/jquery.tablesorter.js" type="text/javascript"></script>
    <script src="Scripts/jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "User.aspx/BindDatatable",
            data: "{}",
            dataType: "json",
            success: function (data) {
                //alert(data.d.length);                
                for (var i = 0; i < data.d.length; i++) {
                    $("#tbDetails").append("<tr><td>" + data.d[i].UserName + "</td><td>" + data.d[i].USerEmailID + "</td><td>" + data.d[i].Active + "</td><td>" + data.d[i].PhoneNumber + "</td></tr>");

                }                        

            },
            error: function (result) {
                alert("Error");
            }
        });
    });
//    $(function () {
//        $("#tbDetails").stupidtable();
//    });
//        $(document).ready(function () {
//           $("#tbDetails").stupidtable();        
//        });

    $(document).ready(function () {
        //$("#tbDetails").tablesorter({ widgets: ['zebra'] });
        $("#tbDetails").tablesorter();
       // $("#tbDetails").tablesorter({ selectorHeaders: '> thead > tr > td' });
    }
);

    $(document).ready(function () {
        $("#tbDetails").tablesorter({ sortList: [[0, 0], [1, 0]] });
    }
); 
    
   
</script>
<style type="text/css">
         .btn1
        {
            background: url("../images/btn_bg.gif") repeat-x scroll center top #015F92;
            border: 1px solid #015F92;
            border-radius: 3px 3px 3px 3px;
            color: #FFFFFF;
            cursor: pointer;
            font-size: 12px;
            font-weight: bold;
            margin: 0;
            padding: 5px 15px;
        }
        a
        {
            outline: medium none;
            text-decoration: none;
        }
        .style1
        {
            width: 100%;
        }
    </style>


  

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="full" id="main_body" align="center">
<div id="droppable">
<table class="style1">
        <tr id="Tr1" align="center"  runat="server">
            <td>
                                      
            </td>
            
            <tr><td align="left" valign="top"> <asp:Button ID="btnNew" runat="server" Text="New..." onclick="btnNew_Click" 
                                              CssClass="btn1" /> <asp:Button ID="btnEdit" 
                    runat="server" Text="Edit..." onclick="btnNew_Click" 
                                              CssClass="btn1" /> <asp:Button 
                    ID="btndelete" runat="server" Text="Delete..." onclick="btnNew_Click" 
                                              CssClass="btn1" /></td></tr>
                                              
 <tr align="center">
 <td> 
 <table class="nrmltbl" id="tbDetails" cellpadding="0" cellspacing="3" border="0" style="border: medium groove #6699FF">
<thead style="border: medium groove #9999FF; background-color:#006699; color:White; font-weight:bold">
<tr style="border: medium ridge #000000">
<td>User Name</td>
<td>User EmaiID</td>
<td>Is Active</td>
<td>Phone Number</td>
</tr>
</thead>
<tbody>
</tbody>
</table></td></tr>
            </table>
</div>
</div>



IN users.aspx.cs following code i done please check it and give me some suggestions.

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using System.Configuration;
using System.Collections;
using BusinessLayer;


namespace FiSoftCustomerPortal
{
    public partial class User : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [WebMethod]
        public static BLUsers[] BindDatatable()
        {
            Encryption clsencrypt = new Encryption();
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            List<blusers> details = new List<blusers>();
            DataSet BindDs = new DataSet();
            BLUsers bluser1 = new BLUsers();
            BindDs = bluser1.BindtabletoUsers();
            clsencrypt.decryptDataSet(BindDs);
            dt = BindDs.Tables[0];
            foreach (DataRow dtrow in dt.Rows)
            {
                BLUsers bluser = new BLUsers();
                bluser.UserName = dtrow["User_Name"].ToString();
                bluser.USerEmailID = dtrow["User_EmailID"].ToString();
                bluser.Active = dtrow["Is_Active"].ToString();
                bluser.PhoneNumber = dtrow["Phone_Number"].ToString();
                details.Add(bluser);
            }
            return details.ToArray();


        }       

        protected void btnNew_Click(object sender, EventArgs e)
        {
            Response.Redirect("ManageUser.aspx");
        }
    }
}
Posted
Updated 9-Oct-12 2:35am
v2
Comments
Zubair Alie 9-Oct-12 8:36am    
if you have a table to sort. why don't you go for DataGridView where sorting & paging are facilitated?
read http://asp-net-example.blogspot.com/2008/12/aspnet-gridview-sorting-example-how-to.html
BalaMahesh 9-Oct-12 10:04am    
that is requirement to binding the values in table please help me ..

1 solution

Try this,

JavaScript
<script src="<%=Page.ResolveClientUrl("~/Scripts/jquery.tablesorter.js") %>" language="javascript" type="text/javascript"></script> 

<script src="<%=Page.ResolveClientUrl("~/Scripts/jquery.tablesorter.min.js") %>" language="javascript" type="text/javascript"></script>


I suppose you are missing the proper reference to tablesorter.js file.
 
Share this answer
 
v3
Comments
BalaMahesh 9-Oct-12 10:03am    
Sorry it is not working..
Give some suggestions
Rajeev Jayaram 9-Oct-12 10:13am    
If the referencing is made ok, then you can also check if the table is not empty before sorting.
BalaMahesh 9-Oct-12 10:23am    
table contains 10 rows still its getting the same error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900