Using WCF Without LINQ - No Data

3 posts, 0 answers
  1. Cognitronic
    Cognitronic avatar
    11 posts
    Member since:
    Sep 2012

    Posted 11 Nov 2009 Link to this post

    Hello,

    I am trying to evaluate the client-side databinding using WCF and am having a hard time getting the desired results.  It appears that I have everything working correctly, and in Firebug I can see that the data is being returned from my WCF method, but it's not showing up in the grid.  Also, it is returning the correct number of rows(it is showing the correct paging information and total row count) but is ignoring the pagesize property.  Here are some snippets:

    <telerik:RadGrid  
                ID="rgTasks"  
                runat="server" 
                AllowPaging="true"  
                ShowHeader="true" 
                ShowStatusBar="true" 
                AutoGenerateColumns="false" 
                Skin="Vista" 
                PageSize="15" 
                AllowSorting="true"
                <MasterTableView  
                DataKeyNames="taskid"  
                AlternatingItemStyle-BackColor="AliceBlue" 
                CommandItemDisplay="Top" 
                NoMasterRecordsText="No tasks found." 
                ClientDataKeyNames="taskid"
                    <CommandItemSettings 
                    ShowExportToWordButton="true" 
                    ShowExportToExcelButton="true" 
                    ShowExportToCsvButton="true" 
                    ShowExportToPdfButton="true"/> 
                    <Columns> 
                        <telerik:GridBoundColumn  
                        DataField="taskid"  
                        HeaderText="Task ID" 
                        DataType="System.Int32"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn  
                        DataField="title"  
                        HeaderText="Title" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                        <%--<telerik:GridTemplateColumn  
                        DataField="description"  
                        SortExpression="description" 
                        HeaderText="Description"
                            <ItemTemplate> 
                                <dp:Label 
                                runat="server" 
                                ID="lblDescription" 
                                Text='<%# FormatTextForGridDisplay(Eval("description").ToString()) %>' 
                                ToolTip='<%# Eval("description") %>'
                                </dp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn>--%> 
                        <telerik:GridBoundColumn  
                        DataField="assignedto"  
                        HeaderText="Assigned To" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn  
                        DataField="status"  
                        HeaderText="Status" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn  
                        DataField="priority"  
                        HeaderText="Priority" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                        <%--<telerik:GridTemplateColumn  
                        DataField="account"  
                        SortExpression="Account" 
                        HeaderText="account"
                            <ItemTemplate> 
                                <dp:Label 
                                runat="server" 
                                ID="lblAccount" 
                                Text='<%# Eval("description") %>'
                                </dp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn>--%> 
                        <telerik:GridBoundColumn  
                        DataField="startdate"  
                        HeaderText="Start Date" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn  
                        DataField="duedate"  
                        HeaderText="Due Date" 
                        DataType="System.String"
                        </telerik:GridBoundColumn> 
                    </Columns> 
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                </MasterTableView> 
                <ClientSettings> 
                    <DataBinding  
                    SelectMethod="GetTasksForList"  
                    SelectCountMethod="GetTasksForListCount" 
                    Location="~/Services/Service.svc" 
                    StartRowIndexParameterName="startIndex" 
                    MaximumRowsParameterName="maxRowCount"
                    </DataBinding> 
                </ClientSettings> 
                </telerik:RadGrid> 

    Here is the service:
    [OperationContract] 
        public TList<Tasks> GetTasksForList(int startIndex, int maxRowCount) 
        { 
            TasksService ts = new TasksService(); 
            TList<Tasks> tlist = ts.GetAll(); 
            return tlist; 
        } 
     
        [OperationContract] 
        public int GetTasksForListCount() 
        { 
            TasksService ts = new TasksService(); 
            return ts.GetAll().Count; 
        } 

    Here is my web.config

    <system.serviceModel> 
            <behaviors> 
                <endpointBehaviors> 
                    <behavior name="ServiceAspNetAjaxBehavior"
                        <enableWebScript/> 
                    </behavior> 
                </endpointBehaviors> 
                <serviceBehaviors> 
                    <behavior name="metadataAndDebug"
                        <serviceMetadata httpGetEnabled="true" httpGetUrl="" /> 
                        <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" /> 
                    </behavior> 
                </serviceBehaviors> 
            </behaviors> 
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
            <services> 
                <service name="Service"
                    <endpoint address="" behaviorConfiguration="ServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="Service"/> 
                    <endpoint address="mex" binding="mexHttpBinding" contract="Service"   /> 
                </service> 
            </services> 
        </system.serviceModel> 



    Thanks!!



  2. Cognitronic
    Cognitronic avatar
    11 posts
    Member since:
    Sep 2012

    Posted 11 Nov 2009 Link to this post

    Ok, so I changed my WCF method to this:
    [OperationContract] 
        public TList<Tasks> GetTasksForList(int startIndex, int rowCount) 
        { 
            int count = 0
            TasksService ts = new TasksService(); 
            return ts.GetPaged(startIndex, rowCount, out count); 
        } 

    And now the grid is rendering properly...with the correct pagesize and virtual item count, but still showing no data!  I can see in the response that the service is returning the correct JSON, there are no errors, the grid displays 5 records per page...just no data in the fields.  Anyone having this issue or know how to fix???


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Nov 2009 Link to this post

    Hello,

    Since JSON binding is case sensitive please check if fields names declared in grid columns are correctly spelled.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top