Mapping or adding a "virtual" column to datatable

Sep 12 2008 11:54 PM

Hi,

I have a dataview that isn't sorting numerically. I'm trying to make a datatable instead, from the dataset for the dataview.  The problem is that there are "virtual" columns, for lack of a better word, that make up some of the columns in the dataview. These are lambda expressions.  Is it possible to add these types of columns that only exist in the dataview to a datatable?

This code is from an application developed by others, I'm trying to modify the sort so it will sort numerically.

This is the dataview code.  The "ViewBuilder" and "setViewLambda" expressions are drawn from other pages in the application.

 DEF_ViewBuilder vb = new DEF_ViewBuilder();
 vb.SetViewLambda( new VersionNumberLambda( "VERSION_NUMBER",  m_versionDataSet.Tables[GetTableName()],this ) );
   vb.SetViewLambda( new VersionClosedLambda( "IS_CLOSED" ) );
   vb.SetViewLambda( new VersionLockLambda( "LOCKED_BY",   m_versionDataSet.Tables[GetTableName()],this ) );
   vb.SetDataSources( "TableName", m_versionDataSet.Tables );

     m_dv = vb.CreateView( "VersionView (VERSION_NUMBER, RELEASE_VERSION_NAME, IS_CLOSED, LOCKED_BY, ID)", "FROM " + GetTableName() + "(ID)" );   

VERSION_NUMBER, RELEASE_VERSION_NAME, IS_CLOSED, LOCKED_BY, ID are the "virtual" columns in the dataview. I need the VERSION_NUMBER sorted, but it's sorting alphanumerically with the dataview.sort method, not numerically. When I add a column to the datatable, I can declare it as an Int32 and sort it then.

I've added a datatable and bound it to a datagrid:

DataTable t = m_versionDataSet.Tables[0];

dgVersions.DataSource = t;

Any ideas or suggestions vastly appreciated.

Thanks,

Anise


Answers (2)