Hi folks, newbie here, apologies in advance if my terminology is wrong . Been using this forum for a bit to answer my questions via the search function while I learn some VB and ASP but I've got something I just can't wrap my mind around
I have a webpage with a form. I'm using a keyed in entry and a drop down list to connect to a database and grab some values to variables based on that entry. Also show those variables in Textboxes. Everything there is working fine.
I'm using a multiview and view1 to show the form on pageload. Once my data is retrieved I have a button that calls view3 in the multiview to look at some more data in the database and do some edits (using values/variables from the first query)
My problem is when the page reloads my variables are being cleared. From my research "ViewState" is what I want to use to preserve their values but I can't figure out how to use it. I've read tutorials on the net and think i understand the logic behind it but can't wrap my head around it programatically
So was wondering if you could possibly dumb it down even more for a newbie and maybe help with an example
Right now on pageload
Clicking the button to go to view 3. This shows a checkboxlist with some values that I read from my first query and is working fine. The user selects which checkbox entries they want to delete from the database and then clicks a 'purge' button where I run some sql commands using variable1, variable2 and the values from the checkedboxlist. Variable1 and variable2 are empty strings though
This is the code calling the function to do the database work "purge button". wod_purge is the function to do the work
I don't understand where in the code to use "ViewState" so that the variable retains it's value
Any help provided would be most welcome. Thanks
I have a webpage with a form. I'm using a keyed in entry and a drop down list to connect to a database and grab some values to variables based on that entry. Also show those variables in Textboxes. Everything there is working fine.
I'm using a multiview and view1 to show the form on pageload. Once my data is retrieved I have a button that calls view3 in the multiview to look at some more data in the database and do some edits (using values/variables from the first query)
My problem is when the page reloads my variables are being cleared. From my research "ViewState" is what I want to use to preserve their values but I can't figure out how to use it. I've read tutorials on the net and think i understand the logic behind it but can't wrap my head around it programatically
So was wondering if you could possibly dumb it down even more for a newbie and maybe help with an example
Right now on pageload
VB.NET:
variable1 = Textbox1.Text
variable2 = Dropdownlist1.SelectedValue
Clicking the button to go to view 3. This shows a checkboxlist with some values that I read from my first query and is working fine. The user selects which checkbox entries they want to delete from the database and then clicks a 'purge' button where I run some sql commands using variable1, variable2 and the values from the checkedboxlist. Variable1 and variable2 are empty strings though
VB.NET:
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
MultiView1.SetActiveView(View3)
End Sub
This is the code calling the function to do the database work "purge button". wod_purge is the function to do the work
VB.NET:
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button4.Click
If CheckBoxList1.SelectedItem.Selected Then
checkedlist.Add(CheckBoxList1.SelectedValue)
End If
wod_purge()
End Sub
I don't understand where in the code to use "ViewState" so that the variable retains it's value
Any help provided would be most welcome. Thanks