I have used the code below to add multiple calculated
columns, but how do, or better, can it be more simplyfied
, because it seems a bit redundant.
Only the last created column matters!
I need an expression that creates a total of the prices bound to
one primary key ID when I navigate threw the gridview!
This is not something I can use I think, because I need an expression based column?
thanks, richard
columns, but how do, or better, can it be more simplyfied
, because it seems a bit redundant.
Only the last created column matters!
I need an expression that creates a total of the prices bound to
one primary key ID when I navigate threw the gridview!
This is not something I can use I think, because I need an expression based column?
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim [/COLOR][/SIZE][SIZE=2]sumObject [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2]sumObject = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DBDataSet.Table1.Compute([/SIZE][SIZE=2][COLOR=#a31515]"Sum(Amount)"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]"YesNo = Yes"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgBox(sumObject.ToString)[/SIZE]
VB.NET:
Private Sub AddColumn()
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cols [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataColumnCollection = _[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DBDataSet.Tables([/SIZE][SIZE=2][COLOR=#a31515]"Table1"[/COLOR][/SIZE][SIZE=2]).Columns[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myCol [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataColumn = _[/SIZE]
[SIZE=2]cols.Add([/SIZE][SIZE=2][COLOR=#a31515]"BedrgOpn"[/COLOR][/SIZE][SIZE=2], System.Type.GetType([/SIZE][SIZE=2][COLOR=#a31515]"System.Decimal"[/COLOR][/SIZE][SIZE=2]), _[/SIZE]
[SIZE=2][COLOR=#a31515]"IIF(YesNo = 1 , 0, Amount)"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cols.Add([/SIZE][SIZE=2][COLOR=#a31515]"TotAmountOpn"[/COLOR][/SIZE][SIZE=2], System.Type.GetType([/SIZE][SIZE=2][COLOR=#a31515]"System.Decimal"[/COLOR][/SIZE][SIZE=2]), _[/SIZE]
[SIZE=2][COLOR=#a31515]"Sum(AmountOpn)"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[COLOR=green]'To the parenttable[/COLOR]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cols2 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataColumnCollection = _[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DBDataSet.Tables([/SIZE][SIZE=2][COLOR=#a31515]"Table0"[/COLOR][/SIZE][SIZE=2]).Columns[/SIZE]
[SIZE=2]cols2.Add([/SIZE][SIZE=2][COLOR=#a31515]"AmountOpn"[/COLOR][/SIZE][SIZE=2], System.Type.GetType([/SIZE][SIZE=2][COLOR=#a31515]"System.Decimal"[/COLOR][/SIZE][SIZE=2]), _[/SIZE]
[SIZE=2][COLOR=#a31515]"Sum(child(FK_Table1_Table0).AmountOpn)"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cols.Add([/SIZE][SIZE=2][COLOR=#a31515]"FinalColumn"[/COLOR][/SIZE][SIZE=2], System.Type.GetType([/SIZE][SIZE=2][COLOR=#a31515]"System.Decimal"[/COLOR][/SIZE][SIZE=2]), _[/SIZE]
[SIZE=2][COLOR=#a31515]"Parent(FK_Table1_Table0).AmountOpn"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000]'for testing[/COLOR][/SIZE]
[SIZE=2]MsgBox(cols(cols.Count - 1).ToString)[/SIZE]
[SIZE=2]myCol.ReadOnly = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2]myCol.Unique = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
End Sub
thanks, richard
Last edited: