We recently had a customer that wanted to sort a dynamic column in a DataGrid and so I thought it may be something that others would like to be able to do.

You get your data for your dynamic column and then do something like below to insert it into an existing DataTable in a DataSet:

Dim dc as new DataColumn
dc.DataType = System.Type.GetType("System.String")
dc.Caption = "DynColumn"
dc.ColumnName = "DynColumn"
 
vServersSet.Tables(0).Columns.Add(dc)
 
For I = 0 To vServersSet.Tables(0).Rows.Count - 1
    Dim get_value As String
    get_value = GetData(I)
    vServersSet.Tables(0).Rows(I).Item("DynColumn") = get_value
Next

Now apply sorting:

vServersSet.Tables(0).DefaultView.Sort = "DynColumn Desc"

This way we can sort on our dynamic column in our grid.  To point the Grid to the table, just using something like:

DataGrid1.DataSource = vServersSet.Tables(0)
DataGrid1.DataBind()