AxpDataGrid

Grid formatting and manipulation

Mix Html, text and data

AxpDataGrid use a special notation for Data column names in some of it's properties and methods. The Column name is the enclosed in a pair of # characters. E.g. if your data source contain a column named ProductName, the notation #ProductName# is used to replace #ProductName# with the Column value.

Html, text and the data column values can then be combined and replace the original cell value.

Examples

Commonly used properties

Using the GridColumns collection

The AxpDataGrid.GridColumns collection is useful when you want to set individual column properties in code. Most of these properties could be set using alternative AxpDataGrid properties and methods, mentioned above, but you might prefer this approach.

[Visual Basic]
Private Sub AxpDataGrid1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxpDataGrid1.Load
  AxpDataGrid1.GridColumns["ProductName"].Caption = "Product Name"
  AxpDataGrid1.GridColumns["ProductName"].CellHtmlAttributes = "style=""text-align:center"""
  AxpDataGrid1.GridColumns["ProductName"].FormatCellFunction = "UCase"
  AxpDataGrid1.GridColumns["ProductName"].FreeFormatCell = "#ProductId#:<strong>#ProductName#</strong>"
  AxpDataGrid1.GridColumns["ProductName"].GridHeadHtmlAttributes = "style=""text-align:center"""
  AxpDataGrid1.GridColumns["ProductName"].Width = "200px"
  AxpDataGrid1.GridColumns["ProductName"].Visible = True ' Default is True, set to False to hide
  AxpDataGrid1.GridColumns["ProductName"].Wrap = False
End Sub      
[C#]
private void AxpDataGrid1_Load(object sender, System.EventArgs e)
{
  AxpDataGrid1.GridColumns["ProductName"].Caption = "Product Name";
  AxpDataGrid1.GridColumns["ProductName"].CellHtmlAttributes = "style=\"text-align:center\"";
  AxpDataGrid1.GridColumns["ProductName"].FormatCellFunction = "UCase";
  AxpDataGrid1.GridColumns["ProductName"].FreeFormatCell = "#ProductId#:<strong>#ProductName#</strong>";
  AxpDataGrid1.GridColumns["ProductName"].GridHeadHtmlAttributes = "style="\"text-align:center\"";
  AxpDataGrid1.GridColumns["ProductName"].Width = "200px";
  AxpDataGrid1.GridColumns["ProductName"].Visible = true; // Default is true, set to false to hide
  AxpDataGrid1.GridColumns["ProductName"].Wrap = false;
}

Remarks

The corresponding AxpDataGrid.FormViewColumns collection can be used for fine grained control in the Form View mode. If a column is present in both Grid and Form View mode, the Form View settings will inherit the settings made in GridColumns. If you specify different property values for a column in Form View, these settings will override any settings made in the GridColumns for the same property.

See Also

AxpDataGrid Tutorial