Intersoft WebGrid Documentation
InitializeChildTableDataSource Event
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > WebGrid Class : InitializeChildTableDataSource Event






Occurs when a child table needs to be initialized during data binding.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute()>
<CategoryAttribute("Behavior")>
Public Event InitializeChildTableDataSource As ChildTableDataSourceEventHandler
Visual Basic (Usage)Copy Code
Dim instance As WebGrid
Dim handler As ChildTableDataSourceEventHandler
 
AddHandler instance.InitializeChildTableDataSource, handler
C# 
[DescriptionAttribute()]
[CategoryAttribute("Behavior")]
public event ChildTableDataSourceEventHandler InitializeChildTableDataSource
Delphi 
public event InitializeChildTableDataSource: ChildTableDataSourceEventHandler; 
JScript 
In JScript, you can handle the events defined by another class, but you cannot define your own.
Managed Extensions for C++ 
[DescriptionAttribute()]
[CategoryAttribute("Behavior")]
public: __event ChildTableDataSourceEventHandler* InitializeChildTableDataSource
C++/CLI 
[DescriptionAttribute()]
[CategoryAttribute("Behavior")]
public:
event ChildTableDataSourceEventHandler^ InitializeChildTableDataSource

Event Data

The event handler receives an argument of type ChildTableDataSourceEventArgs containing data related to this event. The following ChildTableDataSourceEventArgs properties provide information specific to this event.

PropertyDescription
CustomRequestData Gets the custom request data string send from client's request.
DataSource Gets the assigned WebGrid's DataSource object.
ParentConstraints Gets the constraints of parent's WebGridRow object which initiated the event.
ParentKeyValues Gets the constraints of key values' WebGridRow object which initiated the event. 
ParentObject Sets the current object of which collection is retrieved for hierarchical object binding purpose.
ReturnValue (Inherited from ISNet.WebUI.WebGrid.BaseEventArgs) 
Table Gets the WebGridTable object used by the event.

Example

 

The examples below shows the implementation of Load On Demand mechanism in WebGrid.NET Enterprise 4.0
C#Copy Code
private void WebGrid1_InitChildDS(object sender, ISNet.WebUI.WebGrid.ChildTableDataSourceEventArgs e) 
{ 
    if (e.Table.DataMember == "Orders")  
    { 
        DataSet ds = (DataSet) e.DataSource; 
        ds.Orders = BusinessClass.GetOrdersByCustomerID(e.ParentConstraints); 
    } 
 
    else if (e.Table.DataMember == "OrderDetails")  
    { 
        DataSet ds = (DataSet) e.DataSource; 
        ds.OrderDetails = BusinessClass.GetOrderDetailsByOrderID(e.ParentConstraints); 
    } 
}

Remarks

WebGrid was built with scalability and performance as its key design consideration. It is specially designed to work best in enterprise-class environment in which each childTables contains very large dataSource.

WebGrid provides a true "Load On Demand" architecture in which developers has full control over the childTable's dataSource. Developers can decide to load only root level's dataSource on the first page load and then load the childTable's dataSource only on when users click on [+] sign to expand childTable's rows.

You can take advantage of the provided ParentConstraints parameter which is an XML string that contains a pair of constraints and values of the ParentRow; to filter and dynamically load the childTable's dataSource based on the constraints. This enables you to fully control the server's workload and dramatically increases overall performance.

By default, WebGrid is able to handle and load ChildTable's rows automatically based on correct constrains without any additional codes. However, you can choose to override and write your own codes in this event.

In WebGrid.NET Enterprise 5.0 you do not need to write codes in the InitializeChildTableDataSource. There are two ways to provide the method for retrieving child table data:

  • Write codes for the method in App_Code.
    The following codes illustrate the technique to load Orders table when a Customer record is drilled down.

    public DataTable GetData(string customerID)

  {

   dsNorthwind.OrdersDataTable dt = new                 dsNorthwind.OrdersDataTable();  

 

   OleDbDataAdapter adapter = new OleDbDataAdapter();

  

   adapter.SelectCommand = new

   OleDbCommand("SELECT * FROM Orders WHERE CustomerID = '" +        customerID + "'", this.Connection);

   adapter.Fill(dt);

 

   return dt;

  }

    Using this technique, you can assign the ISDataSourceTable’s SelectMethod to GetData.

  • Create the method in Visual Studio 2005’s DataSet Designer.
    Another way to create the data method is through DataSet Designer in Visual Studio 2005. The DataSet Designer enables you to create the method using a visual manner with less coding needed. For more information, please read Walkthrough: Loading child rows based on the selected parent row

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.