M
Mr. SweatyFinger
Hi my checkbox list works great, except when i go to edit the items in the
browser.
It doesn't save the changes.
This routine is supposed to save the newly checked items, instead it saves
out the original ones.
What gives?
Sub insertCategories(ByVal adnum As Integer)
Dim MyItem As ListItem
DBConnection = New
OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString())
Dim SQLString As String
Dim checkboxlist1 As CheckBoxList = FormView1.FindControl("CheckBoxList1")
Dim sqldatasource2 As SqlDataSource =
FormView1.FindControl("sqldatasource2")
sqldatasource2.SelectCommand = "SELECT [category] FROM [categories] WHERE
([summary] = 'gear') ORDER BY [orderby]"
' If Not checkboxlist1 Is Nothing Then
DBConnection.Open()
For Each MyItem In checkboxlist1.Items
If MyItem.Selected = True Then
' SQLString = "insert into ads_categories (adnum, categoryname, state)
values(" & adnum & ",'" & MyItem.Value & "','" & MyItem.Selected.ToString &
"')"
SQLString = "insert into ads_categories (adnum, categoryname ) values(" &
adnum & ",'" & MyItem.Value & "')"
DBCommand = New OleDbCommand(SQLString, DBConnection)
DBCommand.ExecuteScalar()
DBCommand = Nothing
End If
Next
DBConnection = Nothing
' End If
End Sub
browser.
It doesn't save the changes.
This routine is supposed to save the newly checked items, instead it saves
out the original ones.
What gives?
Sub insertCategories(ByVal adnum As Integer)
Dim MyItem As ListItem
DBConnection = New
OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString())
Dim SQLString As String
Dim checkboxlist1 As CheckBoxList = FormView1.FindControl("CheckBoxList1")
Dim sqldatasource2 As SqlDataSource =
FormView1.FindControl("sqldatasource2")
sqldatasource2.SelectCommand = "SELECT [category] FROM [categories] WHERE
([summary] = 'gear') ORDER BY [orderby]"
' If Not checkboxlist1 Is Nothing Then
DBConnection.Open()
For Each MyItem In checkboxlist1.Items
If MyItem.Selected = True Then
' SQLString = "insert into ads_categories (adnum, categoryname, state)
values(" & adnum & ",'" & MyItem.Value & "','" & MyItem.Selected.ToString &
"')"
SQLString = "insert into ads_categories (adnum, categoryname ) values(" &
adnum & ",'" & MyItem.Value & "')"
DBCommand = New OleDbCommand(SQLString, DBConnection)
DBCommand.ExecuteScalar()
DBCommand = Nothing
End If
Next
DBConnection = Nothing
' End If
End Sub