Hello,
I'm trying to populate a RadGrid with data from a WebMethod call, and I'm having no luck. The primary example I'm trying to use (Here) doesn't tell me what type of data to return in the GetData method, and doesn't show example code for the Web Service. Below is my example code, what is wrong with it?
WerbService.asmx Codebehind
I'm trying to populate a RadGrid with data from a WebMethod call, and I'm having no luck. The primary example I'm trying to use (Here) doesn't tell me what type of data to return in the GetData method, and doesn't show example code for the Web Service. Below is my example code, what is wrong with it?
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="Telerik.Web.UI" TagPrefix="tel" Namespace="Telerik.Web.UI" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent" > <asp:Label ID="Label1" runat="server" Text="" /> <tel:RadScriptManager runat="server"></tel:RadScriptManager> <tel:RadGrid ID="RadGrid1" runat="server"> <MasterTableView> <Columns> <tel:GridBoundColumn DataField="ID" HeaderText="ID" DataType="System.Int32" /> </Columns> </MasterTableView> <ClientSettings> <DataBinding Location="Services/WerbService.asmx" SelectMethod="HelloWorld2" /> </ClientSettings> </tel:RadGrid></asp:Content>WerbService.asmx Codebehind
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;using Telerik.Web.UI;/// <summary>/// Summary description for WebService/// </summary>[WebService(Namespace = "WerbServices")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService]public class WerbService : System.Web.Services.WebService { public WerbService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public static object HelloWorld2(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression) { return new[] { new{ID = "Hello World"} }; } }