Hi Telerik
I have radgrid that client binding to WCF (Ajax-enabled) service . that's fine work on locally but on host has problme and can't show data .
please help me . i tired to do it ..
thanks.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
div
>
<
telerik:RadGrid
ID
=
"gvProvince"
runat
=
"server"
AllowMultiRowSelection
=
"True"
AllowFilteringByColumn
=
"True"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowPaging
=
"True"
DataKeyNames
=
"ProvinceId"
ClientDataKeyNames
=
"ProvinceId"
AllowAutomaticDeletes
=
"True"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"RowNumber"
HeaderText
=
"row"
SortExpression
=
"RowNumber"
UniqueName
=
"RowNumber"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ProvinceId"
HeaderText
=
"Province Id"
SortExpression
=
"ProvinceId"
UniqueName
=
"ProvinceId"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"ProvinceName"
HeaderText
=
"Province Name"
SortExpression
=
"ProvinceName"
UniqueName
=
"ProvinceName"
AllowFiltering
=
"False"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
/>
<
ClientItemTemplate
>
#=ProvinceName#
</
ClientItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowColumnsReorder
=
"True"
AllowDragToGroup
=
"True"
ReorderColumnsOnClient
=
"True"
EnableRowHoverStyle
=
"True"
>
<
DataBinding
FilterParameterType
=
"Linq"
Location
=
"~/App/Services/ProvinceService.svc"
ResponseType
=
"JSONP"
SelectMethod
=
"GetProvinces"
SortParameterType
=
"Linq"
>
</
DataBinding
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using RadTest.Models;
using Telerik.Web.UI;
namespace RadTest.App.Services
{
public class ProvinceInformation
{
public int ProvinceId { get; set; }
public string ProvinceName { get; set; }
}
[DataContract]
public class ProvinceInfoService
{
[DataMember]
public int RowNumber { get; set; }
[DataMember]
public int ProvinceId { get; set; }
[DataMember]
public string ProvinceName { get; set; }
}
public class ResultDataProvince
{
public int Count { get; set; }
public List<
ProvinceInfoService
> Data { get; set; }
}
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProvinceService
{
[OperationContract]
public ResultDataProvince GetProvinces(int startRowIndex, int maximumRows, string sortExpression, string filterExpression)
{
var row = startRowIndex;
using (var db = new persianEntities())
{
var lst = (from province in db.Provinces
select new ProvinceInformation()
{
ProvinceId = province.ProvinceId,
ProvinceName = province.ProvinceName
}
).OrderBy(p => p.ProvinceId);
var data = RadGrid.GetBindingData(lst, startRowIndex, maximumRows, sortExpression, filterExpression);
var result = new ResultDataProvince();
result.Data = data.Data.Select(p => new ProvinceInfoService()
{
ProvinceId = p.ProvinceId,
ProvinceName = p.ProvinceName
}).ToList().Select(p => new ProvinceInfoService()
{
RowNumber = ++row,
ProvinceId = p.ProvinceId,
ProvinceName = p.ProvinceName
}).ToList();
result.Count = data.Count;
return result;
}
}
}
}
<?
xml
version
=
"1.0"
?>
<
configuration
>
<
configSections
>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<
section
name
=
"entityFramework"
type
=
"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
</
configSections
>
<
appSettings
>
<
add
key
=
"Telerik.Skin"
value
=
"Default"
/>
<
add
key
=
"Telerik.ScriptManager.TelerikCdn"
value
=
"Disabled"
/>
<
add
key
=
"Telerik.StyleSheetManager.TelerikCdn"
value
=
"Disabled"
/>
<
add
key
=
"Telerik.Web.UI.RenderMode"
value
=
"lightweight"
/>
</
appSettings
>
<
system.web
>
<
compilation
debug
=
"true"
targetFramework
=
"4.5"
/>
<
httpRuntime
targetFramework
=
"4.5"
/>
<
pages
>
<
controls
>
<
add
tagPrefix
=
"telerik"
namespace
=
"Telerik.Web.UI"
assembly
=
"Telerik.Web.UI"
/>
</
controls
>
</
pages
>
<
httpHandlers
>
<
add
path
=
"ChartImage.axd"
type
=
"Telerik.Web.UI.ChartHttpHandler"
verb
=
"*"
validate
=
"false"
/>
<
add
path
=
"Telerik.Web.UI.SpellCheckHandler.axd"
type
=
"Telerik.Web.UI.SpellCheckHandler"
verb
=
"*"
validate
=
"false"
/>
<
add
path
=
"Telerik.Web.UI.DialogHandler.aspx"
type
=
"Telerik.Web.UI.DialogHandler"
verb
=
"*"
validate
=
"false"
/>
<
add
path
=
"Telerik.RadUploadProgressHandler.ashx"
type
=
"Telerik.Web.UI.RadUploadProgressHandler"
verb
=
"*"
validate
=
"false"
/>
<
add
path
=
"Telerik.Web.UI.WebResource.axd"
type
=
"Telerik.Web.UI.WebResource"
verb
=
"*"
validate
=
"false"
/>
</
httpHandlers
>
</
system.web
>
<
system.webServer
>
<
validation
validateIntegratedModeConfiguration
=
"false"
/>
<
handlers
>
<
remove
name
=
"ChartImage_axd"
/>
<
add
name
=
"ChartImage_axd"
path
=
"ChartImage.axd"
type
=
"Telerik.Web.UI.ChartHttpHandler"
verb
=
"*"
preCondition
=
"integratedMode"
/>
<
remove
name
=
"Telerik_Web_UI_SpellCheckHandler_axd"
/>
<
add
name
=
"Telerik_Web_UI_SpellCheckHandler_axd"
path
=
"Telerik.Web.UI.SpellCheckHandler.axd"
type
=
"Telerik.Web.UI.SpellCheckHandler"
verb
=
"*"
preCondition
=
"integratedMode"
/>
<
remove
name
=
"Telerik_Web_UI_DialogHandler_aspx"
/>
<
add
name
=
"Telerik_Web_UI_DialogHandler_aspx"
path
=
"Telerik.Web.UI.DialogHandler.aspx"
type
=
"Telerik.Web.UI.DialogHandler"
verb
=
"*"
preCondition
=
"integratedMode"
/>
<
remove
name
=
"Telerik_RadUploadProgressHandler_ashx"
/>
<
add
name
=
"Telerik_RadUploadProgressHandler_ashx"
path
=
"Telerik.RadUploadProgressHandler.ashx"
type
=
"Telerik.Web.UI.RadUploadProgressHandler"
verb
=
"*"
preCondition
=
"integratedMode"
/>
<
remove
name
=
"Telerik_Web_UI_WebResource_axd"
/>
<
add
name
=
"Telerik_Web_UI_WebResource_axd"
path
=
"Telerik.Web.UI.WebResource.axd"
type
=
"Telerik.Web.UI.WebResource"
verb
=
"*"
preCondition
=
"integratedMode"
/>
</
handlers
>
</
system.webServer
>
<
system.serviceModel
>
<
behaviors
>
<
endpointBehaviors
>
<
behavior
name
=
"RadTest.App.Services.ProvinceServiceAspNetAjaxBehavior"
>
<
enableWebScript
/>
</
behavior
>
</
endpointBehaviors
>
</
behaviors
>
<
serviceHostingEnvironment
aspNetCompatibilityEnabled
=
"true"
multipleSiteBindingsEnabled
=
"true"
/>
<
services
>
<
service
name
=
"RadTest.App.Services.ProvinceService"
>
<
endpoint
address
=
""
behaviorConfiguration
=
"RadTest.App.Services.ProvinceServiceAspNetAjaxBehavior"
binding
=
"webHttpBinding"
contract
=
"RadTest.App.Services.ProvinceService"
/>
</
service
>
</
services
>
</
system.serviceModel
>
<
connectionStrings
>
<
add
name
=
"persianEntities"
connectionString
=
"metadata=res://*/Models.Persian.csdl|res://*/Models.Persian.ssdl|res://*/Models.Persian.msl;provider=System.Data.SqlClient;provider connection string="data source=x.x.x.x;initial catalog=xx;user id=xx;password=xx;MultipleActiveResultSets=True;App=EntityFramework""
providerName
=
"System.Data.EntityClient"
/>
</
connectionStrings
>
<
entityFramework
>
<
providers
>
<
provider
invariantName
=
"System.Data.SqlClient"
type
=
"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"
/>
</
providers
>
</
entityFramework
>
</
configuration
>