VB.NET - How to update computed colunm in datagrid view.

Asked By jere on 29-Oct-10 01:42 AM
hi! im using vb.net 2008 and sql server for my database. i have a counm name, quantity and price. i put expression to my dataset colunm  like this, quantity*price. and when i run my application this error appear..

The column mapping from SourceColumn 'SubTotal' failed because the DataColumn 'SubTotal' is a computed column.
can u help me with this error?

tnx..

John replied to jere on 29-Oct-10 03:49 AM
How are you declaring your datafield in the datasource?  What the error is relating to is that the datasource is trying to map the fieldname from the datarecord to that gridview column, but the column is already set as a calculated field.

To get around this, adjust your select query to only contain the fields that match columns; excluding fields that coorespond to a calculated field.

For example:

Select Price, Quantity from Database = datasource to Gridview that contains the following columns:
Price, Quantity and your calculated column Total.