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.
Unfortunately, activation email could not send to your email. Please try again.

Grid control: Binding with a System.Data.DataTable object

Thread ID:

Created:

Updated:

Platform:

Replies:

121099 Nov 10,2015 12:29 PM Nov 12,2015 10:54 AM ASP.NET Web Forms 1
loading
Tags: Grid
Jorge Pampin
Asked On November 10, 2015 12:29 PM

Hello,

If I bind my grid control with a System.Data.DataTable object by code behind there is no problem:

this.GdCuentas.DataSource = EA.ObtenerTabla(tipoEntidad);
this.GdCuentas.DataBind();

But, if I bind my grid control by WebMethod and WebMethodAdaptor it doesn't work:

 [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static object GetRecursos(Syncfusion.JavaScript.DataManager value,Guid idPadre, string sesion)
        {
            DataResult result = new DataResult();

                SAVE.SAVEDMDB.Sesion.EscenarioAbierto EA = System.Web.HttpContext.Current.Session[sesion] as SAVE.SAVEDMDB.Sesion.EscenarioAbierto;

                SAVE.SAVEDMDB.DataModel.DsEscenario.RecursosDataTable RDT = EA.ObtenerTabla(SAVE.SAVECommon.TipoEntidad.Recursos) as SAVE.SAVEDMDB.DataModel.DsEscenario.RecursosDataTable;

                result.result = RDT;
                result.count = RDT.Rows.Count;
 

            return result;
        }

Why?

Thanks!

Prasanna Kumar Viswanathan [Syncfusion]
Replied On November 12, 2015 10:54 AM

Hi Jorge,

 

Thanks for contacting Syncfusion support.

 

While using webMethod Adapter, we suggest you to convert data table to list before assigning data to the grid.

 

Please find the code example and sample:

 

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
 
    <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowGrouping="true" AllowPaging="True">
        <DataManager Adaptor="WebMethodAdaptor" URL="/Default.aspx/Data"/>
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings>
            <Columns>
                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="100" />
                <ej:Column Field="CustomerID" HeaderText="Customer ID" Width="100" />
                <ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="100" />
            </Columns>
        </ej:Grid>
    <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>"
            SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>  
</asp:Content>
 
-----------------------------------------------------------------------------
public static object Data(Syncfusion.JavaScript.DataManager value)
        {
            var data = GetGridDT();
            DataResult ds = new DataResult();
            DataOperations obj = new DataOperations();
            var emp = (from DataRow row in data.Rows
                       select new OrderTable
                       {
                           OrderID = Convert.ToInt32(row["OrderID"]),
                           CustomerID = row["CustomerID"].ToString(),
                           EmployeeID = Convert.ToInt32(row["EmployeeID"]),
                           ShipCountry = row["ShipCountry"].ToString()
 
                       }).ToList();
            ds.result = obj.Execute(emp, value);
            ds.count = emp.Count;
            return ds;
        }

 

Sample: http://www.syncfusion.com/downloads/support/forum/121099/ze/WebApplication211928991356

 

Regards,

Prasanna Kumar N.S.V


CONFIRMATION

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.

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.

;