Mohamoss & unforgiven,
typeof is a C# operator, in VB.NET you need to use the GetType operator (not
to be confused with the Object.GetType & Type.GetType methods). Also [] is
C#:
Dim parent As New DataTable("Parent")
parent.Columns.Add(New DataColumn("name", GetType(string)))
parent.Columns.Add(New DataColumn("year_of_birth", GetType(decimal)))
parent.Columns.Add(New DataColumn("status", GetType(string)))
parent.Columns.Add(New DataColumn("age", GetType(decimal)))
parent.PrimaryKey = New DataColumn() { parent.Columns("name") }
I normally include the expression on the New DataColumn constructor, rather
then set Expression explicitly, either works.
parent.Columns.Add(new DataColumn("age", GetType(decimal), "the
expression"))
For information on expressions in the DataSet object model see the
DataColumn.Expression help topic.
http://msdn.microsoft.com/library/de...ssiontopic.asp
Hope this helps
Jay
"Mohamoss" <mo************@egdsc.microsoft.com> wrote in message
news:Aw**************@cpmsftngxa06.phx.gbl...
Hi
you can build your datatable object , add your four columns to it then
bind it to the datagrid.
You can build your datatable as follows :
Dim parent As new DataTable("Parent");
parent.Columns.Add(new DataColumn("name", typeof(string)));
parent.Columns.Add(new DataColumn("year_of_birth", typeof(decimal)));
parent.Columns.Add(new DataColumn("status", typeof(string)));
parent.Columns.Add(new DataColumn("age", typeof(decimal)));
parent.PrimaryKey = new DataColumn[] { parent.Columns["name"] };
bound the three first columns Then for the forth columns that will be
calculated add the appropriate expression that would return the calculated
age
parent.Columns["age"].Expression =
"you may but your query ";
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC