dang dang dang checkboxlist

  • Thread starter Thread starter Mr. SweatyFinger
  • Start date Start date
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
 
yes it is enabled!!!
dang dang dang

if i look at the trace it shows that the new items were selected!
yet when i go to that routine it only finds the old items>!

dang dang dang
 
check for Not Page.IsPostback in Page_Load before going to insertCategories
Sub.
bang bang bang!
 
Back
Top