Click here to Skip to main content
12,951,289 members (48,551 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
OriginalGriff 6,084
CHill60 3,480
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,830

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2017
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