C# 将2列gridview相乘,并以新的格式显示结果
我需要将列valorprod*cantidad相乘,并显示一个名为subtotal的新列 代码在这里C# 将2列gridview相乘,并以新的格式显示结果,c#,mysql,C#,Mysql,我需要将列valorprod*cantidad相乘,并显示一个名为subtotal的新列 代码在这里 DataTable dsDetalle = new DataTable("Data"); using (MySqlCommand commandSql = cn.CreateCommand()) { commandSql.CommandType = CommandType.Text; commandSql.CommandText = "select * from
DataTable dsDetalle = new DataTable("Data");
using (MySqlCommand commandSql = cn.CreateCommand())
{
commandSql.CommandType = CommandType.Text;
commandSql.CommandText = "select * from detalle where idVenta=@idVenta and idlocal=@idlocal";
commandSql.Parameters.AddWithValue("@idVenta", txt_boleta.Text);
commandSql.Parameters.AddWithValue("@idlocal", txtlocal.Text);
MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(commandSql);
sqlAdapter.Fill(dsDetalle);
}
您可以动态创建计算列
commandSql.CommandText = @"
SELECT *, ( valorprod * cantidad ) AS subtotal
FROM detalle
WHERE idVenta = @idVenta AND idlocal = @idlocal";