|
Step 1: Create an application based on the Orders table in the Northwind database.
Step 2: Override the CreateWhereClause() and PopulateCustomerIDFilter() methods in
the TableControl class.
For .NET Framework 1.1, add your code customization in the OrdersTableControl class of
ShowOrdersTablePage.aspx.cs, located in
|
...\<Application Folder>\Orders\ShowOrdersTablePage.aspx.cs or .vb
|
For .NET Framework 2.0 and 3.0, add your code customization in the OrdersTableControl class
of ShowOrdersTablePage.Controls.cs, located in
|
...\<Application Folder>\App_Code\Orders\ShowOrdersTablePage.Controls.cs or .vb
|
C#:
public override WhereClause CreateWhereClause()
{
WhereClause wc = base.CreateWhereClause();
if ((wc == null))
{
wc = new WhereClause();
}
if (!this.Page.IsPostBack)
{
wc.iAND(OrdersTable.CustomerID, BaseFilter.ComparisonOperator.EqualsTo, "abc");
}
return wc;
}
protected override void PopulateCustomerIDFilter(string selectedValue, int maxItems)
{
if (!this.Page.IsPostBack)
base.PopulateCustomerIDFilter("abc", maxItems);
else
base.PopulateCustomerIDFilter(selectedValue, maxItems);
}
|
Visual Basic .NET:
Public Overrides Function CreateWhereClause() As WhereClause
Dim wc As WhereClause = MyBase.CreateWhereClause
if (wc Is Nothing) Then
wc = New WhereClause
End If
If Not Me.Page.IsPostBack Then
wc.iAND(OrdersTable.CustomerID, BaseFilter.ComparisonOperator.EqualsTo, “abc")
End If
Return wc
End Function
Protected Overrides Sub PopulateCustomerIDFilter(ByVal selectedValue As String, ByVal maxItems As Integer)
If Not Me.Page.IsPostBack Then
MyBase.PopulateCustomerIDFilter("abc", maxItems)
Else
MyBase.PopulateCustomerIDFilter(selectedValue, maxItems)
End If
End Sub
|
Step 3: Build and run your application.
Note: You can also use a URL parameter instead of a constant string to initialize a
filter value. For example, if the URL parameter is called CustomerID, then you can
C#:
wc.iAND(OrdersTable.CustomerID, BaseFilter.ComparisonOperator.EqualsTo,
this.Page.Request.QueryString["CustomerID"]);
|
Visual Basic .NET:
|
wc.iAND(OrdersTable.CustomerID, BaseFilter.ComparisonOperator.EqualsTo, _
Me.Page.Request.QueryString(“CustomerID”))
|
|