Intersoft WebCombo Documentation
OnInitializeDataSource Method
See Also  Example Send Feedback
ISNet.WebUI.WebCombo Namespace > WebCombo Class : OnInitializeDataSource Method






dataSource
A reference to the dataSource object.
isFlyRequest
queryText
startRow
endRow
rowCount
additionalFilters
isDDClicked

Invoked when data source need to be initialized. It is highly recommended that you use this event to initialize your databinding code for more centralized and easy to maintain codes.

Invoked when data source need to be initialized. It is highly recommended that you use this event to initialize your databinding code for more centralized and easy to maintain codes.

Syntax

Visual Basic (Declaration) 
Public Overridable Function OnInitializeDataSource( _
   ByVal dataSource As Object, _
   ByVal isFlyRequest As Boolean, _
   ByVal queryText As String, _
   ByVal startRow As Integer, _
   ByVal endRow As Integer, _
   ByVal rowCount As Integer, _
   ByVal additionalFilters As String, _
   ByVal isDDClicked As Boolean _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As WebCombo
Dim dataSource As Object
Dim isFlyRequest As Boolean
Dim queryText As String
Dim startRow As Integer
Dim endRow As Integer
Dim rowCount As Integer
Dim additionalFilters As String
Dim isDDClicked As Boolean
Dim value As Boolean
 
value = instance.OnInitializeDataSource(dataSource, isFlyRequest, queryText, startRow, endRow, rowCount, additionalFilters, isDDClicked)
C# 
public virtual bool OnInitializeDataSource( 
   object dataSource,
   bool isFlyRequest,
   string queryText,
   int startRow,
   int endRow,
   int rowCount,
   string additionalFilters,
   bool isDDClicked
)
Delphi 
public function OnInitializeDataSource( 
    dataSource: TObject;
    isFlyRequest: Boolean;
    queryText: String;
    startRow: Integer;
    endRow: Integer;
    rowCount: Integer;
    additionalFilters: String;
    isDDClicked: Boolean
): Boolean; virtual; 
JScript 
public function OnInitializeDataSource( 
   dataSource : Object,
   isFlyRequest : boolean,
   queryText : String,
   startRow : int,
   endRow : int,
   rowCount : int,
   additionalFilters : String,
   isDDClicked : boolean
) : boolean;
Managed Extensions for C++ 
public: virtual bool OnInitializeDataSource( 
   Object* dataSource,
   bool isFlyRequest,
   string* queryText,
   int startRow,
   int endRow,
   int rowCount,
   string* additionalFilters,
   bool isDDClicked
) 
C++/CLI 
public:
virtual bool OnInitializeDataSource( 
   Object^ dataSource,
   bool isFlyRequest,
   String^ queryText,
   int startRow,
   int endRow,
   int rowCount,
   String^ additionalFilters,
   bool isDDClicked
) 

Parameters

dataSource
A reference to the dataSource object.
isFlyRequest
queryText
startRow
endRow
rowCount
additionalFilters
isDDClicked

Return Value

Returns ReturnValue. Event will be cancelled when ReturnValue is False.

Example

C# Example:
C#Copy Code
protected void WebCombo1_InitializeDataSource(object sender, DataSourceEventArgs e)  
{ 
    // the codes will only be executed on first page load, when refresh function invoked 
    // from client, or when the cache is expired/cleared. 
     
    sqlDataAdapter1.Fill(dataSet11.Customers); 
    e.DataSource = dataSet11; 
}
C#Copy Code
protected void WebCombo1_InitData(object sender, DataSourceEventArgs e) 
{
	// the codes will only be executed on first page load, when refresh function invoked
	// from client, or when the cache is expired/cleared.
	
	sqlDataAdapter1.Fill(dataSet11.Customers);
	e.DataSource = dataSet11;
}

Remarks

Instead of writing your databinding code in Page_Load event, it is more effective to use InitializeDataSource event as a central place for the WebCombo's databinding code. By using this event, you are automatically taking advantage of the WebCombo's automatic data caching feature.

Note that you don't need to use IsDataCached anymore to query the DataCache status since that the control will automatically check it and only call this event when it needs DataSource. You also don't need to put it under !IsPostBack or other conditions because the event is only fired on first page load, on refresh, or when the cache has been cleared/expired. Additionally, the databinding code has been very simplified so that you don't have to call DataBind after you assign the DataSource as needed by other controls normally.

WebCombo.NET 4.0 introduces you to a new code-less data binding. With this new databinding concept, programming databind web application is very easy, simple and straightforward. There are no codes that required in the page’s code behind. Unlike in the previous version, you do not need to write codes inside InitializeDataSource event which pass the datasource to e.DataSource.

Instead of writing your databinding code in Page_Load event, it is more effective to use InitializeDataSource event as a central place for the WebCombo's databinding code. By using this event, you are automatically taking advantage of the WebCombo's automatic data caching feature.

Note that you don't need to use IsDataCached anymore to query the DataCache status since that the control will automatically check it and only call this event when it needs DataSource. You also don't need to put it under !IsPostBack or other conditions because the event is only fired on first page load, on refresh, or when the cache has been cleared/expired. Additionally, the databinding code has been very simplified so that you don't have to call WebCombo.DataBind after you assign the DataSource as needed by other controls normally.

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.