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 5 1478
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
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!
"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
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
i know basically what Page.IsPostback
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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:...
|
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...
|
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...
|
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...
|
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 :-...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |