472,805 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

dang dang dang checkboxlist

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.Configuration Manager.ConnectionStrings("MyConnectionString").To String())
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
Jan 3 '07 #1
5 1452
Is viewstate turned on for that control, look inthe properties

"Mr. SweatyFinger" <sw@sw1finger.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.Configuration Manager.ConnectionStrings("MyConnectionString").To String())
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


Jan 3 '07 #2
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
Jan 3 '07 #3
check for Not Page.IsPostback in Page_Load before going to insertCategories
Sub.
bang bang bang!

"Mr. SweatyFinger" <sw@sw1finger.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.Configuration Manager.ConnectionStrings("MyConnectionString").To String())
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



Jan 3 '07 #4
Page.IsPostback is your friend, know when to check for it
"Mr. SweatyFinger" <sw@sw1finger.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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.Configuration Manager.ConnectionStrings("MyConnectionString").To String())
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


Jan 3 '07 #5
i know basically what Page.IsPostback
>

Jan 3 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all...
4
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
4
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something...
5
by: Eirik Eldorsen | last post by:
I'm trying to code a reapter that for each listelement show a checkboxlist. I'm almost there. The only thing I can't figure out is how to set the ID of the checkboxlists. This is my code:...
3
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Patrick.O.Ige | last post by:
I have some boolean value(1 or 0 ) in a table and i want a databinded CheckBoxList to present the selected values on the page.. With CheckBox i know i can se the Checked property like so :-...
0
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.