Last post Feb 03, 2009 02:31 PM by Mikesdotnetting
Jan 31, 2009 10:51 AM|AndyMoireASP|LINK
This should, I hope, be a simple question to answer.
I have a drop down list, which when a user has made a selection and clicked a button will trigger an update to a table. So, my question is how do you pass a selected value from a drop down list to an Access Data Source to update a table?
Jan 31, 2009 01:14 PM|Mikesdotnetting|LINK
You set the DropDownList as the source of the value of a
Jan 31, 2009 04:41 PM|AndyMoireASP|LINK
I have already to do something already. To give you a better idea what I am doing, my drop down list is already bound to an Access Data Source, and this works. The problem I am having is taking the selected item and passing it to a second Access Data Source
run an update query on the table. I can grab the selected item - no problem at all, but when I use my second Access Data Source to run my Update Query, I can't get the Access Data Source to execute the Update Query. Therefore, I think I must be missing a step
some where along the line.
Can you advise me?
Jan 31, 2009 04:59 PM|Mikesdotnetting|LINK
If you show your existing code, someone might be able to identify the problem. Otherwise it's pure guesswork.
Feb 02, 2009 02:00 PM|AndyMoireASP|LINK
I have been trying to crack this myself, but made no head way! Below is my snippet of code:
I have tried to use a parameter tag to hold one value to for the set part of the Update Query, which I hope will be passed when the value from the drop down list is passed to the where clause.
Unfortunately, when I check the table it hasn't updated.
Can someone tell me what I am doing wrong, please?
Feb 02, 2009 03:41 PM|Mikesdotnetting|LINK
Try changing the UpdateCommand to
UPDATE [Employees] SET [NotActive]=1 WHERE [EmployeeID]=@EmployeeID
then remove the parameter for NotActive
Feb 03, 2009 02:23 PM|AndyMoireASP|LINK
Tried this already, and that didn't work either. Any ideas?
Feb 03, 2009 02:31 PM|Mikesdotnetting|LINK
Seems to me that there is no event to fire the UpdateCommand. Go to design view, then click once on the DropDownList to select it. Then hit F4 to bring up its properties. Click the lightning bolt icon to get to its events, then double click the SelectedIndexChanged
event. That will create an event handler in code behind. Within that, add
See if that works. You may also need to add GridView2.DataBind() to refresh the GridView to see any changes.