Skip to content
Advertisement

Insert multiple values from ListBox with stored procedure

I have two related tables, the first called postaDip (IDpostaDip, CODdip, CODposta, from) and the second called cassPosta (IDposta, Desc).

I am trying to insert multiple rows into the postaDip table through a listbox that loads the table cassPosta. For example I would like to insert multiple lines of as many lines as IDs I select in the listbox. With this code I am trying, if I select only one item in the listbox, the same one, it is inserted repeatedly 2 times. If I select multiple elements, only one is entered, twice!

Markup:

Code behind:

This is the stored procedure

Advertisement

Answer

you have a great routine posted.

Just keep in mind that you have two values in a list box. The dispay, value (text), and then the other hidden value (often the PK value).

Just STRONG TYPE the posted routine, and you get this:

So:

So, note how you can get/grab .Value, or .Text

The original code would be fine if you don’t allow multiple rows – but you do.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement