VB.Net Checkbox values

L

LionsDome

Hello,

I have a vb.net page which a bunch of checkboxes. A user can select a
checkbox(s) and hit the submit button to store those values in a SQL
Server table. This works fine with no problem the first time the user
submits. However when user submits a second time while changing some
of the selected boxes the page only re-submits the previosly selected
checkbox values. It's like its storing it somewhere in the cache or
something. My page is ready to launch but cannot for this reason
alone. Any ideas as to what is going on here? Any help would be
greatly appreciated.


Thanks.


Anil
 
M

Mr. Arnold

LionsDome said:
Hello,

I have a vb.net page which a bunch of checkboxes. A user can select a
checkbox(s) and hit the submit button to store those values in a SQL
Server table. This works fine with no problem the first time the user
submits. However when user submits a second time while changing some
of the selected boxes the page only re-submits the previosly selected
checkbox values. It's like its storing it somewhere in the cache or
something. My page is ready to launch but cannot for this reason
alone. Any ideas as to what is going on here? Any help would be
greatly appreciated.

You got View State for the controls enabled? That's one way that old data on
a control can return to the control. How are you repopulating the the
controls on the round trip when the user hit's the Submit button, and the
value for a control has changed?
 
L

LionsDome

You got View State for the controls enabled? That's one way that old data on
a control can return to the control. How are you repopulating the the
controls on the round trip when the user hit's the Submit button, and the
value for a control has changed?

Thanks for response. The values are saved to the database and the
values based on the selected checkboxes get repopulated when the page
is loaded. I set the ViewState for all the checkboxes on the pages to
false and the Page.ViewState to false on page load and I am still
unable to get it to work. Am I missing something here?
 
M

Mr. Arnold

LionsDome said:
Thanks for response. The values are saved to the database and the
values based on the selected checkboxes get repopulated when the page
is loaded. I set the ViewState for all the checkboxes on the pages to
false and the Page.ViewState to false on page load and I am still
unable to get it to work. Am I missing something here?

Is the repopulation of the control being done at PostBack from the database,
and you sure data is being saved to the database?
 
L

LionsDome

Is the repopulation of the control being done at PostBack from the database,
and you sure data is being saved to the database?- Hide quoted text -

- Show quoted text -

When you load the page the first and lets assume the database table is
empty with no records in there. You can select a few checkboxes and
hit the submit button and the values get saved and the page is then
reloaded. When you hit the submit button a second time and select
different checkboxes for soem reason the same checkboxes that were
selected in the first goaround are the only ones that get updated into
the table. Each submit clears out the table for that particular record
id (We have upto 6 different record Id's that user can select from the
dropdown) so I know for a fact that the same ones are getting
populated over and over again. Based on your suggestion, I set the
Viewstate property to false for each checkbox on the page and also set
the page viewstate property to false. I hope I was a little clear in
helping you to understand my problem.

Thanks for taking the time out to help me thru this. I really
appreciate it a lot.

Anil
 
L

LionsDome

When you load the page the first and lets assume the database table is
empty with no records in there. You can select a few checkboxes and
hit the submit button and the values get saved and the page is then
reloaded. When you hit the submit button a second time and select
different checkboxes for soem reason the same checkboxes that were
selected in the first goaround are the only ones that get updated into
the table. Each submit clears out the table for that particular record
id (We have upto 6 different record Id's that user can select from the
dropdown) so I know for a fact that the same ones are getting
populated over and over again. Based on your suggestion, I set the
Viewstate property to false for each checkbox on the page and also set
the page viewstate property to false. I hope I was a little clear in
helping you to understand my problem.

Thanks for taking the time out to help me thru this. I really
appreciate it a lot.

Anil- Hide quoted text -

- Show quoted text -

Mr. Arnold,

Not sure if you read my reply to your previous posting. I was hoping
to get more feedback from you.

When you load the page the first and lets assume the database table
is
empty with no records in there. You can select a few checkboxes and
hit the submit button and the values get saved and the page is then
reloaded. When you hit the submit button a second time and select
different checkboxes for soem reason the same checkboxes that were
selected in the first goaround are the only ones that get updated
into
the table. Each submit clears out the table for that particular
record
id (We have upto 6 different record Id's that user can select from
the
dropdown) so I know for a fact that the same ones are getting
populated over and over again. Based on your suggestion, I set the
Viewstate property to false for each checkbox on the page and also
set
the page viewstate property to false. I hope I was a little clear in
helping you to understand my problem.

Thanks for taking the time out to help me thru this. I really
appreciate it a lot.


Anil
 
M

Mr. Arnold

LionsDome said:
Mr. Arnold,

Not sure if you read my reply to your previous posting. I was hoping
to get more feedback from you.

When you load the page the first and lets assume the database table
is
empty with no records in there. You can select a few checkboxes and
hit the submit button and the values get saved and the page is then
reloaded. When you hit the submit button a second time and select
different checkboxes for soem reason the same checkboxes that were
selected in the first goaround are the only ones that get updated
into
the table. Each submit clears out the table for that particular
record
id (We have upto 6 different record Id's that user can select from
the
dropdown) so I know for a fact that the same ones are getting
populated over and over again. Based on your suggestion, I set the
Viewstate property to false for each checkbox on the page and also
set
the page viewstate property to false. I hope I was a little clear in
helping you to understand my problem.


It seems to me that you have not saved the values to the database. It could
be that you are not trigging the method that saves the values to the
database possibly. Maybe, you need to use a Session object to hold this
information on round trips. Yes, you have to save data and read data from a
database. But does it mean that you must hold state by saving state data to
the database?
 
L

LionsDome

It seems to me that you have not saved the values to the database. It could
be that you are not trigging the method that saves the values to the
database possibly. Maybe, you need to use a Session object to hold this
information on round trips. Yes, you have to save data and read data from a
database. But does it mean that you must hold state by saving state data to
the database?- Hide quoted text -

- Show quoted text -

Mr. Arnold,

Thanks for the response. On the first go around when the table is
empty, the data is saved. I have verified that already. The second
time a user makes a change to the page, I am deleting the existing
recordset and save the data again with the new changes. It is in the
second go around that the changes are not being saved and the original
values selected in the first go around is onyl getting saved
repeatedly. It is here that I was seeking your guidance in trying to
determine why the changes are not getting saved.

Anil
 
M

Mr. Arnold

LionsDome said:
Mr. Arnold,

Thanks for the response. On the first go around when the table is
empty, the data is saved. I have verified that already. The second
time a user makes a change to the page, I am deleting the existing
recordset and save the data again with the new changes. It is in the
second go around that the changes are not being saved and the original
values selected in the first go around is onyl getting saved
repeatedly. It is here that I was seeking your guidance in trying to
determine why the changes are not getting saved.

What do you mean you have deleted the existing recordset? Either you
selected the record, you got its record-id, and you did a delete by
record-id to delete the record.

I'll assume that you have a try/catch in this routine, and in fact, you know
that the record has been deleted, the routine is not blowing-up and is
leaving the existing record that you keep accessing each time, because the
application blew and you don't know about it.
 
L

LionsDome

- Show quoted >



What do you mean you have deleted the existing recordset? Either you
selected the record, you got its record-id, and you did a delete by
record-id to delete the record.

I'll assume that you have a try/catch in this routine, and in fact, you know
that the record has been deleted, the routine is not blowing-up and is
leaving the existing record that you keep accessing each time, because the
application blew and you don't know about it.

Well the page has a dropdown and each dropdown has checkboxes. Each
item in the dropdown has an id associated with it. On the first go
around the id does not exist in the table and if it does exist I have
something in place that deletes all values based on that id. I have
checked this in debug mode and it is working fine. Once the Id has
been deleted, it then reinserts the values in the table. But on the
second go around it inserts the same values it did in the first
goaround regardless of what other checkboxes you might hve checked or
unchecked.

For a fact I know its not blowing up. So there must be something else
in the routine or session that just retains the values selected in the
first goaround. Maybe this is only happening with checkboxes?
 
M

Mr. Arnold

LionsDome said:
For a fact I know its not blowing up. So there must be something else
in the routine or session that just retains the values selected in the
first goaround. Maybe this is only happening with checkboxes?


When and how are you saving the values to the table? Is this being done at
Page_Unload? Are you saving the values in variables, before saving the data
to the table? I'll assume something is happening on the Control's
Change_Event.

How are you retrieving the values and trying to populate the form, which
I'll assume this is being done at Page_Load on the Post_Back.

Now, if you have disabled View_State on the controls, then there should be
no way those controls are being populated, unless you're populating the
controls on the Page_Load event during the PostBack.
 

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

Top