To implement something like this I think the columns would have to be stored in the db as rows and transformed back into columns for presentation in the UI
Table maybe something like this:
RowID TableID VirtualRowID ColmnName ColumnValue
VirtualRowID would be the id that reperesents a row as seen in the UI, RowID could be the real primary key for convenience but VirtualRowID and ColumnName must also have a unique constraint.
To present it in the UI you would have to create a DataTable object in code and make real columns using the distinct ColumnNames for the tableid. Then loop theough the rows to populate the data table, then bind to the data table in the UI.
Hope it makes sense.