简体   繁体   中英

Alternative for Forloop in Asp.net c#

I am in very big trouble because of this forloop & Dropdownlist.
I am developing Inventory Management System & in that ERP I am creating Online Purchase Order & Sell Order.
For SEll Order Page. Suppose I have 10 Different Product In my warehouse and I want to sell 2,000 quantity from each product Now I have list of 10 products on the same page & I have to bind Total 20,000 quantity to the dropdownlist for each product & also I have to looping through it for the 20,000 which will kill the performance of the page

Like this

Product DDl
A :    2,000
B :    2,000
C:    2,000
D:    2,000
E:    2,000
F:    2,000
G:    2,000
H:    2,000
I:    2,000
J:    2,000

Suppose A to J are the list of product & to right side : are the total quantity that I have to bind to ddl by using loop.

One Can only Select Inhand quantity from the Warehouse by using the Dropdownlist. So that One cannot sell more than Inhand Quantity. Suppose I have 20,000 quantity in my warehouse then I have to loop thourgh 20,000 times in Forloop for Inserting that much quantity in my dropdownlist.

Because of 20,000 times looping though the forloop Page is not resopnding Can anyone suggest me the best possible way to achieve this

I'm not sure what you're doing or how.

If you need to check that someone can't sell more items than he has, you can simply ask the DB for the total of items he has , and make sure it's bigger.

You can also save and cache that value, or have it is another field in a table.

Having said that, and assuming it still takes some time to fetch, you can (should? depends on you) use async calls so your gui isn't waiting for the operation to finish.

Change your input field. Instead of a DropDownList , you can use a Textbox with a NumericUpDown control attached. You can set the maximum and minimum values of this to match your inventory system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM