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






Occurs when any data-related functionality is performed before the grid renders data. All data population are done in this event.

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute()>
<CategoryAttribute("Behavior")>
Public Event PrepareDataBinding As DataSourceEventHandler
Visual Basic (Usage)Copy Code
Dim instance As WebGrid
Dim handler As DataSourceEventHandler
 
AddHandler instance.PrepareDataBinding, handler
C# 
[DescriptionAttribute()]
[CategoryAttribute("Behavior")]
public event DataSourceEventHandler PrepareDataBinding
Delphi 
public event PrepareDataBinding: DataSourceEventHandler; 
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 DataSourceEventHandler* PrepareDataBinding
C++/CLI 
[DescriptionAttribute()]
[CategoryAttribute("Behavior")]
public:
event DataSourceEventHandler^ PrepareDataBinding

Event Data

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

PropertyDescription
DataSource Gets or sets the DataSource for the control.
ReturnValue (Inherited from ISNet.WebUI.WebGrid.BaseEventArgs) 

Example

The example below shows you how to retrieve structure on WebGrid in code-behind using PrepareDataBinding event.
C#Copy Code
private void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
   if(!IsPostBack)
   {
       WebGrid1.RetrieveStructure();
   }
}

Remarks

WebGrid.NET provides PrepareDataBinding event which can be used to perform any data-related functionality before it goes to rendering such as dynamically adding or removing Column, GroupColumn and so on. Since that WebGrid implements advanced databinding process, users are not recommended to dynamically modify the structure of the grid in Page_Load event.

In PrepareDataBinding event, developers can conveniently populate all the columns structure. There are many cases that developers forgot to place all "object creation" codes under !IsPostBack condition, so please remember to place WebGrid1.RetrieveStructure() or WebGrid1.RetrieveHierarchicalStructure() under  !IsPostBack condition.

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.