Hello,
I am using List (of T) in webservice to populate data from sql database into html table using ajax call.
I works perfectly but i get error undefined when the populating data exceed 301.
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "frmStudentList.aspx/GetStudentList",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) { alert(response.d); },
failure: function (response) { alert(response.d); },
error: function (response) { alert(response.d); }
});
});
function OnSuccess(response) {
$(function () {
$('[id*=gvCustomers]').prepend($("<thead></thead>").append($(this).find("tr:first"))).DataTable({
"responsive": true, "lengthChange": true, "autoWidth": false,
"sLoadingRecords": {"loadingRecords": "Please wait - loading..."},
lengthMenu: [[10, 20, -1], [10, 20, "All"]],
"buttons": ["copy", "excel", "pdf", "print"],
data: response.d,
columns: [
{ 'data': 'STUDENT_ID' },
{ 'data': 'FULL_NAME' },
{ 'data': 'GENDER' },
{ 'data': 'PROGRAME' },
{ 'data': 'FORM' },
{ 'data': null, title: 'Edit', wrap: true, "render": function (item) { return '<div class="btn-group"> <button type="button" onclick="fnEdit(' + item.STUDENT_ID + ')" class="btn btn-block btn-success btn-xs"><i class="fas fa-pencil-alt"></i> Edit</button></div>' } },
{ 'data': null, title: 'Deactivate', wrap: true, "render": function (item) { return '<div class="btn-group"> <button type="button" onclick="fnDelete(' + item.STUDENT_ID + ')" class="btn btn-block btn-danger btn-xs"><i class="fas fa-trash"></i> Deactivate</button></div>' } },
]
}).buttons().container().appendTo('[id*=gvCustomers_wrapper] .col-md-6:eq(0)');
});
};
<WebMethod()> _
Public Shared Function GetStudentList() As List(Of STD)
Dim strConnString As String = ConfigurationManager.ConnectionStrings("conString").ConnectionString
Using con As New SqlConnection(strConnString)
Using cmd As New SqlCommand("SELECT TOP 5 * FROM STUDENT_RECORD ORDER BY FULL_NAME", con)
Dim STDs As New List(Of STD)()
con.Open()
Using sdr As SqlDataReader = cmd.ExecuteReader()
While sdr.Read()
STDs.Add(New STD() With { _
.STUDENT_ID = sdr("STUDENT_ID").ToString(), _
.FULL_NAME = sdr("FULL_NAME").ToString(), _
.GENDER = sdr("GENDER").ToString(), _
.PROGRAME = sdr("PROGRAME").ToString(), _
.FORM = sdr("FORM").ToString() _
})
End While
End Using
Return STDs
con.Close()
End Using
End Using
End Function
Public Class STD
Public Property STUDENT_ID() As String
Public Property FULL_NAME() As String
Public Property GENDER() As String
Public Property PROGRAME() As String
Public Property FORM() As String
End Class