Intersoft WebCombo Documentation
Retrieving data using Load-on-Demand feature in ISDataSource control
See Also Send comments on this topic.
Intersoft WebCombo > Learning More > Walkthrough: Getting started with WebCombo.NET version 4.0 using SmartTag Designer > Retrieving data using Load-on-Demand feature in ISDataSource control

Glossary Item Box

This walkthrough shows you how to retrieving data using Load-on-Demand feature in ISDataSourcecontrol.

During this walkthrough, you will learn how to do the following:

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Access to the Microsoft Access Northwind database.
  • Visual Studio 2005 Application.

 Step-By-Step Instructions

To create new web application and bind WebCombo to CustomObject

  1. Create DataSet named NorthWind.
  2. Create partial class CustomersTableAdapter.
    C# Copy ImageCopy Code
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.OleDb;
    
    namespace NorthWindTableAdapters
    {    
       public partial class CustomersTableAdapter    
       {        
          public DataTable GetData(int maximumRows, int startRowIndex)        
          {            
             int topRows = startRowIndex + maximumRows;            
             OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT TOP " + topRows + " * FROM Customers", this.Connection);            
             NorthWind.CustomersDataTable baseData = new NorthWind.CustomersDataTable();            
             adapter.Fill(startRowIndex, maximumRows, new DataTable[] { baseData });            
             return baseData;        
          }
    
          public DataTable GetData(int maximumRows, int startRowIndex, string queryText)        
          {            
             NorthWind.CustomersDataTable baseData = new NorthWind.CustomersDataTable();
    
             if (string.IsNullOrEmpty(queryText))                
                queryText = string.Empty;
    
             // do not need to populate data in first load or standard postback, without value (queryText is empty)            
             if (maximumRows == 0 && startRowIndex == 0 && string.IsNullOrEmpty(queryText))                
                return baseData;
    
             if (maximumRows > 0)            
             {                
                 // retrieves a list of data based on given startRow and maxRow                
                 int topRows = startRowIndex + maximumRows;                
                 OleDbDataAdapter adapter = new OleDbDataAdapter("Select TOP " + topRows + " * FROM Customers WHERE ContactName LIKE '" + queryText + "%'", this.Connection);                
                 adapter.Fill(startRowIndex, maximumRows, new DataTable[] { baseData });            
             }            
             else 
             {                    
                // bind to single value, this will be called during first load or postback, and value is filled.                    
               // note that the query is made against value field.                    
               if(!string.IsNullOrEmpty(queryText)) 
               {                        
                  OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Customers Where CustomerID =  '" + queryText + "'", this.Connection);                        
                  adapter.Fill(baseData);                    
               }            
            }            
            return baseData;                  
       }
    
       public int SelectCount(string queryText)        
       {            
             OleDbDataAdapter myDa = new OleDbDataAdapter();
    
             string selectCommand = "Select Count(*) From customers Where contactName like '" + queryText + "%'";            
             myDa.SelectCommand = new OleDbCommand(selectCommand, this.Connection);
    
             this.Connection.Open();            
             int result = (int)myDa.SelectCommand.ExecuteScalar();            
             this.Connection.Close();            
             return result;        
          }    
       }
    }
    
  3. Drag ISDataSource instance from ToolBar to WebForm.
  4. Bind the DataSet to ISDataSource.
  5. Open ISDataSource.NET Designer.
  6. Set EnablePaging = Yes
    SelectCountMethod = "SelectCount"
    MaxiumRowsParameterName ="maximumRows"
    StartRowIndexParameterName
    ="startRowIndex"

  7. Drag WebCombo instance from ToolBar to WebForm.
  8. Click the SmartTag on the upper right of the WebCombo.
  9. Set DataSource to ISDataSource
  10. Set the DataTextField and DataValueField for WebCombo.

 

For more information, please refer to WebCombo.NET V4.0 Sample - LoadOnDemand.aspx

See Also