Last post Dec 03, 2009 04:33 PM by csihosting
Dec 02, 2009 04:25 PM|csihosting|LINK
I have search and search for this but I can't get it to work. I am trying to get an accessdatasource to update a database row and one of the columns the data is coming from a listbox with the selection=multiple on it. Here's my code behind:
Protected Sub AccessDataSource2_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles AccessDataSource2.Updating
Dim selecteditems As String = ""
Dim apps As ListBox = DetailsView1.FindControl("appliances")
Dim i As Integer
For i = 0 To apps.Items.Count - 1
If apps.Items(i).Selected Then
selecteditems += apps.Items(i).Text & ","
selecteditems = selecteditems.Trim(",")
AccessDataSource2.UpdateParameters("appliances").DefaultValue = selecteditems
the response.write displays all of the selected items, but when the datasource updates the database only the first option is in the list. Any ideas?
Dec 03, 2009 04:14 PM|Mikesdotnetting|LINK
From your description, there seems no logical coding reason why you are only getting the first option - especially as you see the full comma-separated string in your Response.Write(). That leaves other possibilities. Do you have another copy of the database
at all? Is it possible you are checking the right one? Are you checking the right table? Have you tried to read the value back out into a web page?
Dec 03, 2009 04:33 PM|csihosting|LINK
looking at the database after post only has the first option and subsequently the web page only shows the first option. If nothing else I could manually build the SQL statement but I'd rather.