Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6579123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:51:33+00:00 2026-05-25T15:51:33+00:00

I am trying to bind Asp.Net Repeater Control for Ajax Data using DataTables Plugin

  • 0

I am trying to bind Asp.Net Repeater Control for Ajax Data using DataTables Plugin but its not working Following is my Code.

    $(document).ready(function () {
                $('#tblMessages').dataTable({
                    "sDom": 'T<"clear">lfrtip',
                    "oLanguage": { "sSearch": "Search the Messages:" },
                    "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
                    "iDisplayLength": 25,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bFilter": true,
                    "sAjaxSource": "../QCDataServices.asmx/GetPatients",
                    "fnServerData": function(sSource, aoData, fnCallback) {
                        aoData.push("{pageSize:'20',pageNumber:'1'}");
                        $.ajax({
                                "type": "POST",
                                "dataType": 'json',
                                "contentType": "application/json; charset=utf-8",
                                "url": sSource,
                                "data": aoData,
                                "success": function (msg) {
                                    fnCallback(msg.d);
                                }
                            });
                    },
                    "sPaginationType": "full_numbers",
                    "oTableTools": {
                        "aButtons": [
                    "copy",
                    "csv",
                    "xls",
                    {
                        "sExtends": "pdf"
                    },
                    "print"
                ]
                    },
                    "aaSorting": [[0, "desc"]]
                });
            });

Here is the Class which is obtained as Json object

    public class PatientGridDataSet
    {
            public int sEcho { get; set; }
            public int iTotalRecords { get; set; }
            public int iTotalDisplayRecord { get; set; }
            public List<Patient> aaData { get; set; }
        }

Here is the Service Method

        [WebMethod(EnableSession=true)]
            public PatientGridDataSet GetPatients(int pageSize, int pageNumber)
            {
                var patlist=Patients("", "", "");
                return new PatientGridDataSet {sEcho = pageNumber,iTotalRecords =         patlist.Count, iTotalDisplayRecord = pageSize, aaData= patlist.Skip(pageSize * pageNumber).Take(pageSize).ToList() };
            }
            [WebMethod(EnableSession = true)]
            public List<Patient> Patients(string searchIn, string Operator, string         searchString)
            {
                List<Patient> result;
                try
                {
                    DataRow[] rows;
                    var table = new dsVw_Patients.vw_PatientsDataTable();
                    var adapter = new vw_PatientsTableAdapter();
                    adapter.Fill(table);
                    //DataTable distinctTable = originalTable.DefaultView.ToTable(         /*distinct*/ true);
                    string hid = Context.Session["HospitalId"] == null ? "0" :         Context.Session["HospitalId"].ToString();
                    string rid = Context.Session["RoleId"] == null ? "0" :         Context.Session["RoleId"].ToString();
                    string uid = Context.Session["UserId"] == null ? "0" :         Context.Session["UserId"].ToString();
                    if (searchIn.Equals(""))
                    {
                        rows = hid.Equals("0") ?         table.DefaultView.ToTable(true).Select("1=1", "PatientName ASC") : table.DefaultView.ToTable(true).Select("HospitalId="+hid, "PatientName ASC");
                        if(rid.Equals("5"))
                            rows = table.DefaultView.ToTable(true).Select("UserId="+uid,         "PatientName ASC");
                    }
                    else
                    {
                        if (hid.Equals("0"))
                        {
                            rows = Operator.Contains("%") ?         table.DefaultView.ToTable(true).Select(searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select(searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                        }
                        else
                        {
                            rows = Operator.Contains("%") ?         table.DefaultView.ToTable(true).Select("HospitalId=" + hid+" and "+searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select("HospitalId=" + hid + " and " + searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                        }
                        if (rid.Equals("5"))
                        {
                            rows = Operator.Contains("%") ?         table.DefaultView.ToTable(true).Select(searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select(searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                        }
                    }

                    var tieup=new clsTieUpCompanies();
                    result = rows.Select(row => new Patient
                                                    {
                                                        PatientId =         Convert.ToInt32(row["PatientId"]), PatientName = row["PatientName"].ToString(), Address = row["Address"].ToString(), Street = row["Street"].ToString(), City = row["City"].ToString(), ContactNo = row["Contactno"].ToString(), MobileNo = row["MobileNo"].ToString(), Email = row["Email"].ToString(), State = row["State"].ToString(), Country = row["Country"].ToString(), BPLCardNo = row["BPLCardNo"].ToString(), Company = tieup.GetTieupCompanyName(Convert.ToInt32(row["CompanyId"]))
                                                    }).ToList();
                }
                catch (Exception)
                {
                    result = null;
                }
                return result;
            }

First Of when i call my webservice method it does not go there please tell me rest code is ok or not
Here is the markup

      <asp:Repeater ID="rptList" runat="server">
        <HeaderTemplate>
            <table id="tblMessages">
                <thead>
                    <tr>
                        <th>
                            Patient Name
                        </th>
                        <th>
                            Address
                        </th>
                        <th>
                            City
                        </th>
                        <th>
                            Contact No
                        </th>
                        <th>
                        MobileNo
                        </th>
                        <th>
                        BPL Card No.
                        </th>
                    </tr>
                </thead>
                <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <%# Eval("PatientName")%>
                </td>
                <td>
                    <%#Eval("Address")%>
                </td>
                <td>
                    <%# Eval("City")%>
                </td>
                <td>
                    <%# Eval("ContactNo")%>
                </td>
                <td>
                  <%# Eval("MobileNo")%>
                </td>
                <td>
                  <%# Eval("BPLCardNo")%>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </tbody> </table>
        </FooterTemplate>
    </asp:Repeater>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:51:34+00:00Added an answer on May 25, 2026 at 3:51 pm

    @Tim B James

    I have got it worked.But the very reason i tried used it for is defied. It takes a lot of time to fetch only 80 records. Here Find my client code.

        $(document).ready(function () {
                    var grid = $('#tblMessages').dataTable({    
                         "sDom": 'T<"clear">lfrtip',
                        "oLanguage": { "sSearch": "Search the Messages:" },
                        "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
                        "iDisplayLength": 25,                
                        "oTableTools": {
                            "aButtons": [
                        "copy",
                        "csv",
                        "xls",
                        {
                            "sExtends": "pdf"
                        },
                        "print"
                    ]
                        },    
                        "bProcessing": true,
                        "bSort": true,
                        "sPaginationType": "full_numbers",                
                        "bServerSide": true,                                
                        "sAjaxSource": "../QCDataServices.asmx/GetPatients",                                
                        "fnServerData": function (sSource, aoData, fnCallback) {
                            var jsonAOData = JSON.stringify(aoData);
                            $.ajax({
                                type: "POST",
                                //dataType: "json",
                                contentType: "application/json; charset=utf-8",
                                url: sSource,
                                data: "{jsonAOData : '" + jsonAOData + "'}",
                                success: function (msg) {                            
                                    fnCallback(JSON.parse(msg.d));
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert(XMLHttpRequest.status);
                                    alert(XMLHttpRequest.responseText);
    
                                } 
                            });
                        },
    
                        "aoColumnDefs": [
                            { "fnRender": function (oObj) {
                                return "<a href='../FrmMessage.aspx?id='" +         oObj.aData[0] + "><img src='../../images/SMS.png'/></a>";
                            },
                                "bSortable": false,
                                "aTargets": [0]
                            },
                            { "sName": "PatientName",
                                "bSearchable": true,
                                "aTargets": [1]
                            },
                            { "sName": "Address",
                                "bSearchable": true,
                                "bSortable": true,
                                "aTargets": [2]
                            },
                            { "sName": "ContactNo", "aTargets": [3] },
                            { "sName": "MobileNo", "aTargets": [4] },                   
                            { "sName": "BPL Card No", "aTargets": [5] }
                        ]
                    });
                    grid.fnSetFilteringDelay(1000);
                });
    

    I have used Solution provided by this link
    http://activeengine.wordpress.com/2011/02/09/datatablepager-now-has-multi-column-sort-capability-for-datatables-net/

    My Webservice Methods are

         [WebMethod(EnableSession = true)]
         [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
         public string GetPatients(string jsonAOData)
         {         
             var patients= Patients("", "", "");            
             var dataTablePager = new DataTablePager<Patient>(jsonAOData, patients);
             var formattedList = dataTablePager.Filter();
             return JsonConvert.SerializeObject(formattedList);           
         }
    
         [WebMethod(EnableSession = true)]
        public IQueryable<Patient> Patients(string searchIn, string Operator, string searchString)
        {
            IQueryable<Patient> result ;
            try
            {
                DataRow[] rows;
                var table = new dsVw_Patients.vw_PatientsDataTable();
                var adapter = new vw_PatientsTableAdapter();
                adapter.Fill(table);
                //DataTable distinctTable = originalTable.DefaultView.ToTable( /*distinct*/ true);
                var hid = Context.Session["HospitalId"] == null ? "0" : Context.Session["HospitalId"].ToString();
                var rid = Context.Session["RoleId"] == null ? "0" : Context.Session["RoleId"].ToString();
                var uid = Context.Session["UserId"] == null ? "0" : Context.Session["UserId"].ToString();
                if (searchIn.Equals(""))
                {
                    rows = hid.Equals("0") ? table.DefaultView.ToTable(true).Select("1=1", "PatientName ASC") : table.DefaultView.ToTable(true).Select("HospitalId="+hid, "PatientName ASC");
                    if(rid.Equals("5"))
                        rows = table.DefaultView.ToTable(true).Select("UserId="+uid, "PatientName ASC");
                }
                else
                {
                    if (hid.Equals("0"))
                    {
                        rows = Operator.Contains("%") ? table.DefaultView.ToTable(true).Select(searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select(searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                    }
                    else
                    {
                        rows = Operator.Contains("%") ? table.DefaultView.ToTable(true).Select("HospitalId=" + hid+" and "+searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select("HospitalId=" + hid + " and " + searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                    }
                    if (rid.Equals("5"))
                    {
                        rows = Operator.Contains("%") ? table.DefaultView.ToTable(true).Select(searchIn + " like '" + Operator.Replace("_", searchString) + "'", searchIn + " ASC") : table.DefaultView.ToTable(true).Select(searchIn + " " + Operator + " '" + searchString + "'", searchIn + " ASC");
                    }
                }
                //.Skip(pageSize*pageNumber).Take(pageSize).ToList().
                var tieup=new clsTieUpCompanies();
                result = rows.Select(row => new Patient
                                                {
                                                    PatientId = Convert.ToInt32(row["PatientId"]), PatientName = row["PatientName"].ToString(), Address = row["Address"].ToString(), Street = row["Street"].ToString(), City = row["City"].ToString(), ContactNo = row["Contactno"].ToString(), MobileNo = row["MobileNo"].ToString(), Email = row["Email"].ToString(), State = row["State"].ToString(), Country = row["Country"].ToString(), BPLCardNo = row["BPLCardNo"].ToString(), Company = tieup.GetTieupCompanyName(Convert.ToInt32(row["CompanyId"]))
                                                }).AsQueryable();
            }
            catch (Exception)
            {
                result = null;
            }
            return  result;
        }
    

    Please guide how to improve the performacnce.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to use this code to bind my asp.net menu control to
I am trying to bind an ASP.NET GridView control to an string array and
I'm using ASP.NET MVC RC1 and trying to bind a textbox to an object
I am using asp.net membership and trying to update a users details but get
im trying to bind a ItemsControl to use as an Repeater (Asp.net) inside a
I am trying to bind some values to an ASP.NET Chart control. This is
I'm trying to bind an ASP.net DropDownList to the results of an entity framework
I have a ASP.net gridview that I am trying bind to. My DataSource has
Im trying to bind a dropdownlist in ASP.NET MVC to a class. Luckily for
I am using a dropdown list in ASP.NET with C#. I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.