Intersoft Support Center

Implement Load-on-Demand in Self-Referencing Data

This walkthrough shows you how to create Self Reference LoadOnDemand in WebGrid.

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

  • Setting a Self Reference Load On Demand in a WebGrid.

 Prerequisites

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

  • Access to the Microsoft Access Northwind Database.
  • Visual Studio 2005/2008/2010 Application.

 Step-By-Step Instructions

To create new web Website and specify Self Reference LoadOnDemand in WebGrid.

  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. Right-click on Project's name and select Add New Item.
  6. Select Intersoft AppForm in the My Templates box and named it as Walkthrough.aspx.
  7. In the Solution Explorer, right-click on App_Code and select Add New Item.
  8. Choose DataSet and named it as dsNorthwind.xsd.
  9. Open Server Explorer and expand Northwind tables. Add the entire tables to create the DataSet.
  10. Drag WebGrid control to the WebForm. Open WebGrid.NET Designer and go to Advanced.
  11. Select RootTable.
  12. Check the Enable Self Referencing checkbox.
  13. Set ParentDataMember to EmployeeID.
  14. Set ChildDataMember to ReportsTo.
  15. Set ExpandColumnMember to FirstName.
    SelfRefDes

  16. Drag ISDataSource control from toolbox to the designer surface.
  17. Configure Data Source for the newly created ISDataSource.
  18. Select DataSet for the SchemaType.
  19. Click Schema Name dropdown and select dsNorthWind from the list.
  20. In the next dialog, click Add button then select Employees in the dropdown menu.
  21. In the Select Method dropdown list, select GetDataBy(Nullable<Int32> ReportsTo) method. 
  22. Click Finish.

    ISDSSelfRef1

  23. Open ISDataSource Designer.
  24. Click on Employees table.
  25. Set SelectSelfReferenceRowMethod to GetDataBy.

    ISDSSElfRef2

  26. Drag WebGrid control from toolbox to the designer surface.
  27. Set the DataSourceID to ISDataSource1.

    a

  28. In the Connect to DataSource dialog, select Retrieve  Structure, choose "Employees" table then click OK.
  29. Open WebGrid Designer >> Advanced and click See all properties.
  30. Expand SelfReferencingSettings, set Enabled to True, set ExpandColumnMember to FirstName, set ChildDataMember to ReportsTo and ParentDataMember to EmployeeID.
  31. In SelfReferencingSettings, remember to set LoadOnDemand to True.

    SelfRefLOD
Previous Next