Intersoft WebGrid Documentation
Walkthrough: Configuring WebService client-binding to return paged data
See Also Send comments on this topic.

Glossary Item Box

This walkthrough shows you how to configure WebService on a client-binding WebGrid to return paged data.

During this walkthrough, you will learn how to do the following:

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Access to BugTracker.mdf database.
  • Visual Studio 2008 Application.

 Step-By-Step Instructions

To configure WebService client-binding to return paged data

  1. Launch Visual Studio.NET 2008.
  2. Click on File menu, then select New and click Web Site.
  3. Select ASP.NET Web Site in the Template box and set Location to HTTP.
  4. Named the Web Site and click OK.
  5. In the Solution Explorer, right-click on App_Data and select Add Existing Item.
  6. Browse and add BugTracker.mdf in C:\Program Files\Intersoft Solutions\WebUI Studio for ASP.NET\Data (Default installation folder).
  7. In the Solution Explorer, right-click on App_Code and select Add New Item.
  8. Create a new LINQ to SQL Class and named it BugTrackerModel.dbml.
  9. Drag and drop the Bugs table from the server explorer.




  10. Right-click on Project's name and select Add New Item.
  11. Select Web Service in the My Templates box and named it as WebService.asmx.
  12. Add a  new WebMethod GetPagedBugs in the WebService.cs located in App_Code.

    C# Copy Code
    [WebMethod]
    public object GetPagedBugs(DataSourceSelectArguments selectArguments)
    {  
       BugTrackerModelDataContext context = new BugTrackerModelDataContext();  
       context.DeferredLoadingEnabled = false;
       var pagedData = context.Bugs.AsQueryable();
                            
       // handle sorting  
       if (!string.IsNullOrEmpty(selectArguments.SortExpression))    
          pagedData = pagedData.OrderBy(selectArguments.SortExpression);
                            
       // handle filtering  
       if (!string.IsNullOrEmpty(selectArguments.FilterExpression))    
          pagedData = pagedData.Where(selectArguments.GetLinqFilterExpression());   
    
       if (selectArguments.OperationType == SelectOperation.SelectData)  
       { 
          // handle paging    
          if (selectArguments.MaximumRows > 0)
             pagedData = pagedData.Skip(selectArguments.StartRowIndex).Take(selectArguments.MaximumRows - selectArguments.StartRowIndex);
             return pagedData.ToList();  
       }  
       else if (selectArguments.OperationType == SelectOperation.SelectCount)
          return pagedData.Count();  
          throw new InvalidOperationException("Unsupported operation type!");
    }                           
    

  13. Right-click on Project's name and select Add New Item.
  14. Select Intersoft AppForm in the My Templates box and named it as Walkthrough.aspx.
  15. Drag WebGrid instance from ToolBar to WebForm.
  16. Click the SmartTag on the upper right of the WebGrid and click the WebGrid.NET Designer link to open the Designer.
  17. In the Popular Setting page, set PagingMode to ClassicPaging and PagingSize to 15.



  18. On the Data Source (Advanced) page, use Client-side binding and connect to a WebService. Insert WebService.asmx to the service URL, Bug in the Item Type Name, and GetPagedBugs in the SelectMethod.



  19. Click OK.
  20. You are all set. Run the page in browser.

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.