Sort Data

Handle Sort Event

Description
This customization demonstrates how to handle the sort event for the column sorting link at the top of a table panel.
Variables
Database Table
Select the database table displayed in the page
Table Control Class
Select a table control
Field Label
Select the field label corresponding to the field to be sorted
Field Name
Select the database field to be sorted
Applies to
TableControl class
Code
     
/// 
/// Override the ${Field Label}_Click to customize the sort order
/// 
public override void ${Field Label}_Click(object sender, EventArgs args)
{
    OrderByItem sd  = this.CurrentSortOrder.Find(${${Database Table}ClassName}.${Field Name});    
    if (!(sd == null))
    {
        sd.Reverse();
    }
    else
    {
        this.CurrentSortOrder.Reset();

        // Set the sort order for the selected field
        this.CurrentSortOrder.Add(${${Database Table}ClassName}.${Field Name}, BaseClasses.Data.OrderByItem.OrderDir.Asc);        
    }
    this.DataChanged = true;
}
     

Terms of Service Privacy Statement