dang dang dang checkboxlist

  • Thread starter Mr. SweatyFinger
  • 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
 
M

Mr. SweatyFinger

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
 
S

Saber

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top