Export Data

Customize Exported File Columns

This customization shows how to write your own custom code for the Export button in the show table page to limit the number of columns that needs to be exported or to format the data in a certain format, other than the default format exported by Iron Speed Designer.
Export Button
Select the export button
Select a database table associated with the Export button
Primary Key
Select primary key in the table
Export Field
Select a field to export to the .csv file
Applies to
P_Export Button class
/// Override the ${Export Button}_Click and customize the 
/// export button functionality
/// Also if the export button is Image button then, second parameter type is ImageClickEventArgs.
/// If the button is of "Button" type then modify the parameter type to EventArgs.
public override void ${Export Button}_Click(object sender, ImageClickEventArgs args)
        WhereClause whereStr = this.CreateWhereClause();
        //Create the order by object
        BaseClasses.Data.OrderBy ob = null;
        int pageIndex = 0;
        int pageSize = 1000;
        // Get the instance of Data Access class
        ${${Table}RecordClassName}[] recList = ${${Table}ClassName}.GetRecords(whereStr, ob, pageIndex, pageSize);        
        string exportedData = "";
        exportedData = this.ExportFunction(recList);
        // Export the data.
        this.Page.AttachFile("MyFile.csv", exportedData);
    catch (Exception ex) 
        // Report error message to the user
       BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);

/// This method limits the number of columns that get exported.
public string ExportFunction( ${${Table}RecordClassName}[] recList)
    //  Add column names to the export data.
    string exportLine = ${${Table}ClassName}.${Primary Key}.InternalName + ",";
    exportLine += ${${Table}ClassName}.${Export Field}.InternalName + ",";    

    // Finally, add the line break after adding the last column heading.
    string exportedData = (exportLine + "\r\n");

    // Get column values from each record in table.  
    foreach (${${Table}RecordClassName} rec in recList)
        exportLine = "";
        exportLine += rec.${Primary Key} + ",";
        exportLine += rec.${Export Field} + ",";

        // Add the line break after each record.           
        exportedData +=  exportLine + "\r\n";
    return exportedData;

Terms of Service Privacy Statement