What should you do to ensure that the Total column is set to the value of the Price column multiplied?

You are creating a DataTable. You use the following code segment to create the DataTable. (Line numbers are included for reference only.)

01 Dim dt As New DataTable("Products")
02 dt.Columns.Add(New DataColumn("Price", _GetType(Decimal))) 03 dt.Columns.Add(New DataColumn("Quantity", _GetType(Int32))) 04 Dim dc As DataColumn = New DataColumn("Total", _GetType(Decimal)) 05 dt.Columns.Add(dc)

You need to ensure that the Total column is set to the value of the Price column multiplied by the Quantity column when new rows are added or changed. What should you do?

You are creating a DataTable. You use the following code segment to create the DataTable. (Line numbers are included for reference only.)

01 Dim dt As New DataTable(“Products”)
02 dt.Columns.Add(New DataColumn(“Price”, _GetType(Decimal))) 03 dt.Columns.Add(New DataColumn(“Quantity”, _GetType(Int32))) 04 Dim dc As DataColumn = New DataColumn(“Total”, _GetType(Decimal)) 05 dt.Columns.Add(dc)

You need to ensure that the Total column is set to the value of the Price column multiplied by the Quantity column when new rows are added or changed. What should you do?

A.
Add the following code segment after line 05. dc.ExtendedProperties[“Total”] = “Price * Quantity”

B.
Add the following code segment after line 05. dc.Expression = “Price * Quantity”

C.
Write an event handler for the DataTable’s TableNewRow event that updates the row’s Total.

D.
Write an event handler for the DataTable’s ColumnChanged event that updates the row’s Total.



Leave a Reply 0

Your email address will not be published. Required fields are marked *