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>
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
http://stackoverflow.com/questions/380451/c-how-do-i-do-i-loop-through-items-in-a-list-box-and-then-remove-that-item
Do you want to update the database, based on some condition, like which items are selected in the ListBox?
ASKER
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.
field 1 : update with the listbox items index
where listbox DataValueField = SameValueinDB.
You have not indicated a programming language...
ASKER
VB.NET sorry.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it might be helpful if you can povide us with more details