Click here to Skip to main content
12,398,225 members (58,363 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
on my web form i have a multiple selection list box control in which user can select any number of lot_code, in the next text box i want to display total cost of all the selected lot_codes from sql server data table.
how can i implement this please help.

Posted 9-Dec-12 5:39am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Ruby,

Implement your logic as below.

protected void btn_Click(object sender, EventArg e)
   string lot_code ="";
   foreach(Item item in lstBox.Items)
   //Execute below query to get the result from the database
   //"Select sum(cost) from tableName where lot_code IN ("+lot_code+");"
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You may use something like this (error handling left to the reader)
int sum = 0;
foreach (object item in myListBox.SelectedItems)
  DataRow [] dr"lot_code = " int.Parse(item.tostring()));
  sum += dr[0]["cost"];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100