Link to home
Start Free TrialLog in
Avatar of GPSAddict
GPSAddict

asked on

.NET Listbox loop DB Update

Hi, how can I, upon a button click, loop through a listbox items and update my binded database like this: use the actual listbox index and update the DB field CATEGORY_ID. See my listbox code below. Code needed. Thanks
<asp:ListBox ID="lstDisplayOrder" runat="server" DataSourceID="odsOrderByDisplay" 
                                DataTextField="DESCRIPTION_E" DataValueField="CATEGORY_ID" 
                                Width="300px" SelectedValue='<%# Bind("CATEGORY_ID") %>' Rows="8"></asp:ListBox>

Open in new window

Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

it really not clear what functionality you are trying to achieve
it might be helpful if you can povide us with more details
Avatar of GPSAddict
GPSAddict

ASKER

I need to code to loop through a listbox and then update a table using the listbox items index....
i am still not clear what you want to achieve but you can loop a listbox as explained in the following example
http://stackoverflow.com/questions/380451/c-how-do-i-do-i-loop-through-items-in-a-list-box-and-then-remove-that-item
Avatar of Bob Learned
Do you want to update the database, based on some condition, like which items are selected in the ListBox?
No....When I click on a button I want some code to loop through the listbox items and update a table...
field 1 : update with the listbox items index
where listbox DataValueField = SameValueinDB.
You have not indicated a programming language...
VB.NET sorry.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How do I get the item index in the loop because this is the value I want to update with, not the text or value.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial