This walkthrough shows you how to load PreviewRow on demand.
During this walkthrough, you will learn how to do the following:
- Use AccessDataSource.
- Use SmartTag to set DataSource.
- Use Data Source Configuration Wizard to set the Database and table.
Prerequisites
In order to complete this walkthrough, you will need the following:
- Visual Studio 2005 Application.
- Access to the Microsoft Access Northwind database.
Step-By-Step Instructions
- Binding WebGrid.NET to AccessDataSource.
- Use Employees table instead of Customers table.
- Open WebGrid.NET Designer - RootTable.
- Set PreviewRowVisible to True.
- In PreviewRowSettings, set DefaultExpanded to False and LoadOnDemand to True.
- In LoadPreviewRow server side event, add the following code:
C# Copy Code using ISNet.WebUI.WebGrid; protected void WebGrid1_LoadPreviewRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { if (e.Row.Type == ISNet.WebUI.WebGrid.RowType.Record) { e.Row.PreviewRowValue = ((DataRowView)e.Row.DataRow)["Notes"]; WebGrid grid = sender as WebGrid; grid.ClientAction.SetStatus("Ready."); } }
- Compile and run the project. The WebGrid will look like following.