jQWidgets Forums

jQuery UI Widgets Forums Grid asp.net web forms server paging?

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 13 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • asp.net web forms server paging? #4062

    eformx
    Member

    I am using asp.net vb.net web forms (not MVC).  I am able to pull data via a webmethod and that works great.  Code attached.  How can I include server paging (c# example/solution is fine)?

    //in default.aspx

    $(document).ready(function () {

    //Getting the source data with ajax GET request
    source = {
    datatype: “xml”,
    datafields: [
    { name: ‘CompanyName’ },
    { name: ‘ContactName’ },
    { name: ‘ContactTitle’ },
    { name: ‘City’ },
    { name: ‘Country’ },
    { name: ‘Address’ }
    ],
    async: false,
    record: ‘Table’,
    url: ‘Default2.aspx/GetCustomers’
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    { contentType: ‘application/json; charset=utf-8’}
    );
    $(“#jqxgrid”).jqxGrid({
    source: dataAdapter,
    theme: ‘classic’,
    sortable: true,
    pageable: true,
    autoheight: true,
    columns: [
    { text: ‘Company Name’, dataField: ‘CompanyName’, width: 250 },
    { text: ‘Contact Name’, dataField: ‘ContactName’, width: 150 },
    { text: ‘Contact Title’, dataField: ‘ContactTitle’, width: 180 },
    { text: ‘Address’, dataField: ‘Address’, width: 180},
    { text: ‘City’, dataField: ‘City’, width: 80 },
    { text: ‘Country’, dataField: ‘Country’, width: 100}
    ]
    });
    });

    //in code behind

    Imports System.Collections.Generic
    Imports System.Linq
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Web.Services
    Imports System.Web.Script.Services
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Configuration
    Imports System.Web.Script.Serialization

    Partial Public Class Default2
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    End Sub
    <WebMethod()> _
    <ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Xml)> _
    Public Shared Function GetCustomers() As String
    Dim query As String = “SELECT * FROM Customers”
    Dim cmd As New SqlCommand(query)
    ‘ Populate the DataSet.
    Dim data As DataSet = GetData(cmd)
    ‘ return the Customers table as XML.
    Dim writer As New System.IO.StringWriter()
    data.Tables(0).WriteXml(writer, XmlWriteMode.WriteSchema, False)
    Return writer.ToString()
    End Function
    Private Shared Function GetData(ByVal cmd As SqlCommand) As DataSet
    Dim strConnString As String = ConfigurationManager.ConnectionStrings(“cnn_Northwind”).ConnectionString
    Using con As New SqlConnection(strConnString)
    Using sda As New SqlDataAdapter()
    cmd.Connection = con
    sda.SelectCommand = cmd
    Using ds As New DataSet()
    sda.Fill(ds)
    Return ds
    End Using
    End Using
    End Using
    End Function
    End Class

    asp.net web forms server paging? #4078

    Peter Stoev
    Keymaster

    Hi eformx,

    We’ve prepared a blog post about server side paging implementation in ASP .NET application. Please take a look at it here: jquery-grid-server-side-paging-with-asp-net.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.