protected void btn_Click(object sender, EventArg e) { string lot_code =""; foreach(Item item in lstBox.Items) { if(item.IsSelected) lot_code+="'"+item.SelectedItem.Text+"',"; } lot_code.TrimEnd(","); //Execute below query to get the result from the database //"Select sum(cost) from tableName where lot_code IN ("+lot_code+");" }
int sum = 0; foreach (object item in myListBox.SelectedItems) { DataRow [] dr =myDataTable.select("lot_code = " int.Parse(item.tostring())); sum += dr[0]["cost"]; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)