We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

XML binding

Thread ID:





121131 Nov 12,2015 06:28 PM UTC Nov 16,2015 12:43 PM UTC ASP.NET Web Forms 3
Tags: Grid
Jorge Pampin
Asked On November 12, 2015 06:28 PM UTC


How to bind the Grid with a XML returned by a PageMethod? The binding must be by javascript code and the PageMethod has parameter.


Jayaprakash Kamaraj [Syncfusion]
Replied On November 13, 2015 12:24 PM UTC

Hi Jorge,
We have created a sample for binding datasource for the Grid from server using “PageMethods”. Please refer to the code example.

Code Example:


<%--Enable PagerMethods--%>

<asp:ScriptManager runat="server" EnablePageMethods="true">



   <ej:Button Type="Button" runat="server" ClientSideOnClick="btnClick" Text="button"></ej:Button>

<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True">
. . . . 

<script type="text/javascript">

    function btnClick(args) {


       PageMethods.GetCityNameArray(keyvalue, OnSuccessGetCityNameArray);


    function OnSuccessGetCityNameArray(response) {

        // here we get xml data

        var jsondata = …;// here We want to change xmltojson 

        var gridObj = $('#<%= OrdersGrid.ClientID %>').data("ejGrid");






  public static object GetCityNameArray(string[] cities)


            var data = new NorthwndDataContext().Orders.Take(10).ToList();

            var count = new NorthwndDataContext().Orders.Count();

            var xmlString = GetXMLString(data, count);

            return xmlString;


        public static string GetXMLString(IEnumerable<Order> list, int count)


            var xml = new XElement("Orders", from ord in list

                                             select new XElement("Order",

                                            new XElement("OrderID", ord.OrderID),

                                            new XElement("EmployeeID", ord.EmployeeID),

                                            new XElement("CustomerID", ord.CustomerID),

                                            new XElement("Freight", ord.Freight),

                                                            new XElement("ShipName", ord.ShipName)

                                                        ), new XElement("Count", count));

            return xml.ToString();


Note: We need to convert xml data to proper json format to bind with ejGrid.


Jayaprakash K.

Jorge Pampin
Replied On November 13, 2015 02:41 PM UTC

I'ts perfect! Thanks!

Prasanna Kumar Viswanathan [Syncfusion]
Replied On November 16, 2015 12:43 PM UTC

Hi Jorge,

We are happy that the provided solution working fine at your end.

Prasanna Kumar N.S.V


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon