2017-01-12 4 views
-1

мне нужно умножить столбец valorprod * cantidad и отображения нового Колум с именем итогаУмножить 2 colums из GridView и отображать результат в новом

enter image description here

код здесь

DataTable dsDetalle = new DataTable("Data"); 
using (MySqlCommand commandSql = cn.CreateCommand()) 
{ 
     commandSql.CommandType = CommandType.Text; 
     commandSql.CommandText = "select * from detalle where [email protected] and [email protected]"; 
     commandSql.Parameters.AddWithValue("@idVenta", txt_boleta.Text); 
     commandSql.Parameters.AddWithValue("@idlocal", txtlocal.Text); 
     MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(commandSql); 
     sqlAdapter.Fill(dsDetalle); 
} 

ответ

0

Вы можете создать колонку расчета «на лету».

commandSql.CommandText = @" 
    SELECT *, (valorprod * cantidad) AS subtotal 
    FROM detalle 
    WHERE idVenta = @idVenta AND idlocal = @idlocal"; 
+0

спасибо, что код работает –