Dear NG,
After being away from C# programming for a spell, I am trying my hand at
what should be a simple task. I have been hitting my head against the wall
this morning. I have a simple order entry application. The code below gets
line items from a SQL Server database and returns them to a datagrid by way
of a DataTable called lineTable. As long as I am just displaying columns in
the SQL database everything works well. I now want to display a 12th column
computed as extended price. That column is NOT in the table but is computed
by the line: extPrice = Convert.ToDecim al(dr[3]) * Convert.ToDecim al(dr[7]);
As long as I display it in a MessageBox all is well. I have defined a
column 12 using the Collection Editor. I had hoped that by setting the
MappingName property to extPrice I would be home free, but no such luck.
Any help would be appreciated.
Sincerely,
Robert Schuldenfrei (bo*@s-i-inc.com)
private void btnGet_Click(ob ject sender, System.EventArg s e)
{
decimal extPrice;
coHeader = CustomerOrderTb l.GetCoHeader(t xtOrderNo.Text) ;
if (coHeader == null)
{
MessageBox.Show ("Invalid customer order number.", "Entry error");
}
else
{
ShowData(); //display header
//display line items in datagrid
DataTable lineTable = CustomerOrderTb l.GetLines(txtO rderNo.Text);
// Instead of a MessageBox display, I want the extended price to
// appear in column 12 of the data grid. Column [3] is quantity.
// Column [7] is unit price.
foreach (DataRow dr in lineTable.Rows)
{
extPrice = Convert.ToDecim al(dr[3]) * Convert.ToDecim al(dr[7]);
MessageBox.Show (extPrice.ToStr ing());
}
grdLine.DataSou rce = lineTable;
}
} //end btnGet_Click()