R
Robert Schuldenfrei
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.ToDecimal(dr[3]) * Convert.ToDecimal(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 ([email protected])
private void btnGet_Click(object sender, System.EventArgs e)
{
decimal extPrice;
coHeader = CustomerOrderTbl.GetCoHeader(txtOrderNo.Text);
if (coHeader == null)
{
MessageBox.Show("Invalid customer order number.", "Entry error");
}
else
{
ShowData(); //display header
//display line items in datagrid
DataTable lineTable = CustomerOrderTbl.GetLines(txtOrderNo.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.ToDecimal(dr[3]) * Convert.ToDecimal(dr[7]);
MessageBox.Show(extPrice.ToString());
}
grdLine.DataSource = lineTable;
}
} //end btnGet_Click()
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.ToDecimal(dr[3]) * Convert.ToDecimal(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 ([email protected])
private void btnGet_Click(object sender, System.EventArgs e)
{
decimal extPrice;
coHeader = CustomerOrderTbl.GetCoHeader(txtOrderNo.Text);
if (coHeader == null)
{
MessageBox.Show("Invalid customer order number.", "Entry error");
}
else
{
ShowData(); //display header
//display line items in datagrid
DataTable lineTable = CustomerOrderTbl.GetLines(txtOrderNo.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.ToDecimal(dr[3]) * Convert.ToDecimal(dr[7]);
MessageBox.Show(extPrice.ToString());
}
grdLine.DataSource = lineTable;
}
} //end btnGet_Click()