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.
In order to complete this walkthrough, you will need the following:
- Access to the Microsoft Access Northwind Database.
- Visual Studio 2005/2008/2010 Application.
To create new web Website and specify Self Reference LoadOnDemand in WebGrid.
- Launch Visual Studio.NET 2008.
- Click on File menu, then select New and click
Web Site.
- Select ASP.NET Web Site in the Template box and set Location
to HTTP.
- Named the Web Site and click OK.
- Right-click on Project's name and select Add New Item.
- Select Intersoft AppForm in the My Templates box and named it as
Walkthrough.aspx.
- In the Solution Explorer, right-click on App_Code and select
Add New Item.
- Choose DataSet and named it as dsNorthwind.xsd.
- Open Server Explorer and expand Northwind tables. Add the entire tables
to create the DataSet.
- Drag WebGrid control to the WebForm. Open WebGrid.NET Designer
and go to Advanced.
- Select RootTable.
- Check the Enable Self Referencing checkbox.
- Set ParentDataMember to EmployeeID.
- Set ChildDataMember to ReportsTo.
- Set ExpandColumnMember to FirstName.
- 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 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 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.