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:
- Visual Studio 2005/2008/2010 Application.
Step-By-Step Instructions
To create new web application and specify Self Reference LoadOnDemand in WebGrid.
- Open WebGrid.NET Designer, Advanced, click See All Properties.
- Select RootTable.
- Expand SelfReferenceSettings.
- Set ParentDataMember to EmployeeID.
- Set ChildDataMember to ReportsTo.
- Set ExpandColumnMember to FirstName.
- Set Enabled to True.
- Drag ISDataSource control from toolbox to the designer surface.
- Configure Data Source for the newly created ISDataSource.
- Select DataSet for the SchemaType.
- Click Schema Name dropdown and select dsNorthWind from the list.
- In the next dialog, click Add button then select Employees in the dropdown menu.
- In the Select Method dropdown list, select GetDataBy(Nullable<Int32> ReportsTo) method.
- Click Finish.
- Open ISDataSource .NET Designer.
- Click on Employees table.
- Set SelectSelfReferenceRowMethod to GetDataBy.
- Drag WebGrid control from toolbox to the designer surface.
- Set the DataSourceID to ISDataSource1.
- In the Connect to DataSource dialog, select Retrieve Structure, choose "Employees" table then click OK.
- Open WebGrid.NET Designer >> Advanced and click See all properties.
- Expand SelfReferencingSettings, set Enabled to True, set ExpandColumnMember to FirstName, set ChildDataMember to ReportsTo and ParentDataMember to EmployeeID.
- In SelfReferencingSettings, remember to set LoadOnDemand to True.
Tasks
Walkthrough: Creating Self Reference WebGrid
How-to: Remove (+) sign for Self Reference LoadOnDemand rows that contain no Child Row
References
SelfReferencingSettings Class
ChildDataMember Property
Enabled Property
ExpandColumnMember Property
LoadOnDemand Property
ParentDataMember Property
PreviewRowSettings Class
Other Resources
Walkthrough Topics
How-to Topics