Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How to load 2000+ Records using Ajax Webmethod

$
0
0

Hi experts,

I have a problem in loading a thousand records using ajax it gives me an error "internal Error 500". it can only handled less than 500 records

How can i overcome this problem. Please see my code below thanks in advance.

Webmethod in code Behind

<WebMethod()> _
    Public Shared Function BindDataCountryState(ByVal LocationCode As String) As List(Of ListItem)
        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
        Dim CountryState As New List(Of ListItem)()
        Try
  Using con
                Using cmd As New SqlCommand("usp_GetCountryState")
                    cmd.CommandType = CommandType.StoredProcedure
                    cmd.Parameters.AddWithValue("@LocationCode", LocationCode)

                    cmd.Connection = con
                    con.Open()
                    Using sdr As SqlDataReader = cmd.ExecuteReader()
                        While sdr.Read()
                            CountryState.Add(New ListItem() With { _
                              .Value = sdr("Code").ToString(), _
                              .Text = sdr("Description").ToString() _
                            })
                        End While
                    End Using
                    Return CountryState

                End Using
            End Using


        Catch ex As Exception
            HttpContext.Current.Session("error_message") = ex.Message &"
             Return CountryState
        Finally
            If con IsNot Nothing Then
                con.Close()
                con.Dispose()
            End If

        End Try
    End Function

Asp.net Code

var f = document.getElementById("<%=DropDownListPetitionerCountry.ClientID%>");
f.onchange();
var LocationCode = $(f).val();

var parameter = { LocationCode: LocationCode };$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Default.aspx/BindDataCountryState", data: JSON.stringify(parameter), dataType: "json", ////data: '{}', success: function (f) { var ddlCustomers = $("[id*=DropDownListStateProvince]");$.each(f.d, function () { ddlCustomers.append($("<option></option>").val(this['Value']).html(this['Text'])); }); }, error: function (result) { alert("Error " + result.status); console.log(result.status) } });


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>