|
 |
aspdotnet_website_programming thread: viewstate question
Message #1 by Greg Partin <GPartin@c...> on Thu, 11 Apr 2002 10:02:59 -0400
|
|
Hi folks,
I'm trying to 'save' state information for a page in a database for later
retrieval. The reason behind this is for users to be able to save specific
reporting criteria. I'm having a little trouble with the code. I have a
textbox on a page called txtReportName. In my codebehind page, I have a
function that is called onclick. All I want to do is store the state of
txtReportName in a string and insert it into the database. The following
code does not work, test is never set to anything. Is the syntax incorrect?
Am I not understanding how viewstate's statebag works? The way I am
imagining it is viewstate is a hashtable with the control names and the
state in the table.
Dim test As String
test = viewstate("txtReportName")
Any help or suggestions would be appreciated.
thanks,
Greg
Message #2 by TLAMOT@s... on Fri, 12 Apr 2002 12:13:07 -0500
|
|
I would avoid using the viewState entirely if you can.
ASP.NET re-constitutes the control states from the
viewstate state bag during each round trip, including
an onClick event. This means that you can just pull
the text from the control itself rather than the bag.
Therefore, you can just do this:
Dim test as String
test = txtReportName.Text
Hope this helps.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] viewstate
question
>Hi folks,
>
>I'm trying to 'save' state information for a page in
a database for later
>retrieval. The reason behind this is for users to
be able to save specific
>reporting criteria. I'm having a little trouble
with the code. I have a
>textbox on a page called txtReportName. In my
codebehind page, I have a
>function that is called onclick. All I want to do
is store the state of
>txtReportName in a string and insert it into the
database. The following
>code does not work, test is never set to anything.
Is the syntax incorrect?
>Am I not understanding how viewstate's statebag
works? The way I am
>imagining it is viewstate is a hashtable with the
control names and the
>state in the table.
>
>Dim test As String
>test = viewstate("txtReportName")
>
>Any help or suggestions would be appreciated.
>
>thanks,
>Greg
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
Message #3 by Greg Partin <GPartin@c...> on Fri, 12 Apr 2002 15:17:03 -0400
|
|
Thanks, that does clear things up a bit. But how can I use the 'text' from
the control to recreate the page, say, a week later if I store it in a
database? I could have a column called subject_dropdown_text and fill it
with whatever the user chose but then how do I use that value to recreate
the dropdown with the proper value selected?
thanks again,
Greg
-----Original Message-----
From: TLAMOT@s... [mailto:TLAMOT@s...]
Sent: Friday, April 12, 2002 1:13 PM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] Re: viewstate question
I would avoid using the viewState entirely if you can.
ASP.NET re-constitutes the control states from the
viewstate state bag during each round trip, including
an onClick event. This means that you can just pull
the text from the control itself rather than the bag.
Therefore, you can just do this:
Dim test as String
test = txtReportName.Text
Hope this helps.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] viewstate
question
>Hi folks,
>
>I'm trying to 'save' state information for a page in
a database for later
>retrieval. The reason behind this is for users to
be able to save specific
>reporting criteria. I'm having a little trouble
with the code. I have a
>textbox on a page called txtReportName. In my
codebehind page, I have a
>function that is called onclick. All I want to do
is store the state of
>txtReportName in a string and insert it into the
database. The following
>code does not work, test is never set to anything.
Is the syntax incorrect?
>Am I not understanding how viewstate's statebag
works? The way I am
>imagining it is viewstate is a hashtable with the
control names and the
>state in the table.
>
>Dim test As String
>test = viewstate("txtReportName")
>
>Any help or suggestions would be appreciated.
>
>thanks,
>Greg
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.338 / Virus Database: 189 - Release Date: 3/14/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.346 / Virus Database: 194 - Release Date: 4/10/2002
Message #4 by TLAMOT@s... on Fri, 12 Apr 2002 15:24:22 -0500
|
|
You would simply retrieve the value from the database
a week later (or whatever), and then set the value of
your text control.
e.g.
Dim test as String
' ** retrieve data from the database into the test
field
txtReportName.Text = test
After you do the above line, then ASP.NET will auto-
populate your text control with that value.
I hope this answers your question as I didn't quite
understand what you were trying to accomplish.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] Re:
viewstate question
>Thanks, that does clear things up a bit. But how
can I use the 'text' from
>the control to recreate the page, say, a week later
if I store it in a
>database? I could have a column called
subject_dropdown_text and fill it
>with whatever the user chose but then how do I use
that value to recreate
>the dropdown with the proper value selected?
>
>thanks again,
>Greg
>
>-----Original Message-----
>From: TLAMOT@s...
[mailto:TLAMOT@s...]
>Sent: Friday, April 12, 2002 1:13 PM
>To: Website Programming with ASP.NET
>Subject: [aspdotnet_website_programming] Re:
viewstate question
>
>
>I would avoid using the viewState entirely if you
can.
>ASP.NET re-constitutes the control states from the
>viewstate state bag during each round trip,
including
>an onClick event. This means that you can just pull
>the text from the control itself rather than the bag.
>
>Therefore, you can just do this:
>
>Dim test as String
>test = txtReportName.Text
>
>Hope this helps.
>--- Original Message ---
>From: Greg Partin <GPartin@c...>
>To: "Website Programming with ASP.NET"
><aspdotnet_website_programming@p...>
>Subject: [aspdotnet_website_programming] viewstate
>question
>
>>Hi folks,
>>
>>I'm trying to 'save' state information for a page
in
>a database for later
>>retrieval. The reason behind this is for users to
>be able to save specific
>>reporting criteria. I'm having a little trouble
>with the code. I have a
>>textbox on a page called txtReportName. In my
>codebehind page, I have a
>>function that is called onclick. All I want to do
>is store the state of
>>txtReportName in a string and insert it into the
>database. The following
>>code does not work, test is never set to anything.
>Is the syntax incorrect?
>>Am I not understanding how viewstate's statebag
>works? The way I am
>>imagining it is viewstate is a hashtable with the
>control names and the
>>state in the table.
>>
>>Dim test As String
>>test = viewstate("txtReportName")
>>
>>Any help or suggestions would be appreciated.
>>
>>thanks,
>>Greg
>>
>>to unsubscribe send a blank email to leave-
>aspdotnet_website_programming-1076044R@p...
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.338 / Virus Database: 189 - Release
Date: 3/14/2002
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.346 / Virus Database: 194 - Release
Date: 4/10/2002
>
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
Message #5 by Greg Partin <GPartin@c...> on Fri, 12 Apr 2002 17:18:41 -0400
|
|
I'm sorry, I guess I didn't explain myself clearly enough. The user will be
using drop down boxes to dynamically create a query that runs a report. The
values that I need to store are the values in the drop down boxes. A week
later (or whenever) I need to be able to re-establish those drop-down boxes
with the values that I stored from the original query. In ASP I would do
something like this:
sql = "select drop_down_value from saved_report where user_id = 52"
rsDropDown = sql.execute()
if rsDropDown("drop_down_value") = current_drop_down_value then
response.write("selected")
end if
But I have no idea how to do this in ASP.NET Does this clear things up a
little?
thanks again,
Greg
-----Original Message-----
From: TLAMOT@s... [mailto:TLAMOT@s...]
Sent: Friday, April 12, 2002 4:24 PM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] Re: viewstate question
You would simply retrieve the value from the database
a week later (or whatever), and then set the value of
your text control.
e.g.
Dim test as String
' ** retrieve data from the database into the test
field
txtReportName.Text = test
After you do the above line, then ASP.NET will auto-
populate your text control with that value.
I hope this answers your question as I didn't quite
understand what you were trying to accomplish.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] Re:
viewstate question
>Thanks, that does clear things up a bit. But how
can I use the 'text' from
>the control to recreate the page, say, a week later
if I store it in a
>database? I could have a column called
subject_dropdown_text and fill it
>with whatever the user chose but then how do I use
that value to recreate
>the dropdown with the proper value selected?
>
>thanks again,
>Greg
>
>-----Original Message-----
>From: TLAMOT@s...
[mailto:TLAMOT@s...]
>Sent: Friday, April 12, 2002 1:13 PM
>To: Website Programming with ASP.NET
>Subject: [aspdotnet_website_programming] Re:
viewstate question
>
>
>I would avoid using the viewState entirely if you
can.
>ASP.NET re-constitutes the control states from the
>viewstate state bag during each round trip,
including
>an onClick event. This means that you can just pull
>the text from the control itself rather than the bag.
>
>Therefore, you can just do this:
>
>Dim test as String
>test = txtReportName.Text
>
>Hope this helps.
>--- Original Message ---
>From: Greg Partin <GPartin@c...>
>To: "Website Programming with ASP.NET"
><aspdotnet_website_programming@p...>
>Subject: [aspdotnet_website_programming] viewstate
>question
>
>>Hi folks,
>>
>>I'm trying to 'save' state information for a page
in
>a database for later
>>retrieval. The reason behind this is for users to
>be able to save specific
>>reporting criteria. I'm having a little trouble
>with the code. I have a
>>textbox on a page called txtReportName. In my
>codebehind page, I have a
>>function that is called onclick. All I want to do
>is store the state of
>>txtReportName in a string and insert it into the
>database. The following
>>code does not work, test is never set to anything.
>Is the syntax incorrect?
>>Am I not understanding how viewstate's statebag
>works? The way I am
>>imagining it is viewstate is a hashtable with the
>control names and the
>>state in the table.
>>
>>Dim test As String
>>test = viewstate("txtReportName")
>>
>>Any help or suggestions would be appreciated.
>>
>>thanks,
>>Greg
>>
>>to unsubscribe send a blank email to leave-
>aspdotnet_website_programming-1076044R@p...
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.338 / Virus Database: 189 - Release
Date: 3/14/2002
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.346 / Virus Database: 194 - Release
Date: 4/10/2002
>
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.338 / Virus Database: 189 - Release Date: 3/14/2002
Message #6 by TLAMOT@s... on Fri, 12 Apr 2002 17:28:43 -0500
|
|
Assuming that a variable called 'dropDownValue' is
the value you obtained from the database, you would
do the following:
dropDownList.SelectedIndex =
dropDownList.Items.IndexOf(dropDownValue)
I don't have VS.NET up right now to verify, but I
think that syntax is good.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] Re:
viewstate question
>I'm sorry, I guess I didn't explain myself clearly
enough. The user will be
>using drop down boxes to dynamically create a query
that runs a report. The
>values that I need to store are the values in the
drop down boxes. A week
>later (or whenever) I need to be able to re-
establish those drop-down boxes
>with the values that I stored from the original
query. In ASP I would do
>something like this:
>
>sql = "select drop_down_value from saved_report
where user_id = 52"
>
>rsDropDown = sql.execute()
>
>if rsDropDown("drop_down_value") =
current_drop_down_value then
> response.write("selected")
>end if
>
>But I have no idea how to do this in ASP.NET Does
this clear things up a
>little?
>
>thanks again,
>Greg
>
>-----Original Message-----
>From: TLAMOT@s...
[mailto:TLAMOT@s...]
>Sent: Friday, April 12, 2002 4:24 PM
>To: Website Programming with ASP.NET
>Subject: [aspdotnet_website_programming] Re:
viewstate question
>
>
>You would simply retrieve the value from the
database
>a week later (or whatever), and then set the value
of
>your text control.
>
>e.g.
>
>Dim test as String
>' ** retrieve data from the database into the test
>field
>txtReportName.Text = test
>
>After you do the above line, then ASP.NET will auto-
>populate your text control with that value.
>
>I hope this answers your question as I didn't quite
>understand what you were trying to accomplish.
>--- Original Message ---
>From: Greg Partin <GPartin@c...>
>To: "Website Programming with ASP.NET"
><aspdotnet_website_programming@p...>
>Subject: [aspdotnet_website_programming] Re:
>viewstate question
>
>>Thanks, that does clear things up a bit. But how
>can I use the 'text' from
>>the control to recreate the page, say, a week later
>if I store it in a
>>database? I could have a column called
>subject_dropdown_text and fill it
>>with whatever the user chose but then how do I use
>that value to recreate
>>the dropdown with the proper value selected?
>>
>>thanks again,
>>Greg
>>
>>-----Original Message-----
>>From: TLAMOT@s...
>[mailto:TLAMOT@s...]
>>Sent: Friday, April 12, 2002 1:13 PM
>>To: Website Programming with ASP.NET
>>Subject: [aspdotnet_website_programming] Re:
>viewstate question
>>
>>
>>I would avoid using the viewState entirely if you
>can.
>>ASP.NET re-constitutes the control states from the
>>viewstate state bag during each round trip,
>including
>>an onClick event. This means that you can just pull
>>the text from the control itself rather than the
bag.
>>
>>Therefore, you can just do this:
>>
>>Dim test as String
>>test = txtReportName.Text
>>
>>Hope this helps.
>>--- Original Message ---
>>From: Greg Partin <GPartin@c...>
>>To: "Website Programming with ASP.NET"
>><aspdotnet_website_programming@p...>
>>Subject: [aspdotnet_website_programming] viewstate
>>question
>>
>>>Hi folks,
>>>
>>>I'm trying to 'save' state information for a page
>in
>>a database for later
>>>retrieval. The reason behind this is for users to
>>be able to save specific
>>>reporting criteria. I'm having a little trouble
>>with the code. I have a
>>>textbox on a page called txtReportName. In my
>>codebehind page, I have a
>>>function that is called onclick. All I want to do
>>is store the state of
>>>txtReportName in a string and insert it into the
>>database. The following
>>>code does not work, test is never set to
anything.
>>Is the syntax incorrect?
>>>Am I not understanding how viewstate's statebag
>>works? The way I am
>>>imagining it is viewstate is a hashtable with the
>>control names and the
>>>state in the table.
>>>
>>>Dim test As String
>>>test = viewstate("txtReportName")
>>>
>>>Any help or suggestions would be appreciated.
>>>
>>>thanks,
>>>Greg
>>>
>>>to unsubscribe send a blank email to leave-
>>aspdotnet_website_programming-1076044R@p...
>>
>>
>>
>>
>>---
>>Incoming mail is certified Virus Free.
>>Checked by AVG anti-virus system
>(http://www.grisoft.com).
>>Version: 6.0.338 / Virus Database: 189 - Release
>Date: 3/14/2002
>>
>>
>>---
>>Outgoing mail is certified Virus Free.
>>Checked by AVG anti-virus system
>(http://www.grisoft.com).
>>Version: 6.0.346 / Virus Database: 194 - Release
>Date: 4/10/2002
>>
>>
>>to unsubscribe send a blank email to leave-
>aspdotnet_website_programming-1076044R@p...
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.338 / Virus Database: 189 - Release
Date: 3/14/2002
>
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
Message #7 by Greg Partin <GPartin@c...> on Mon, 15 Apr 2002 11:19:41 -0400
|
|
Thanks! That worked perfectly.
Greg
-----Original Message-----
From: TLAMOT@s... [mailto:TLAMOT@s...]
Sent: Friday, April 12, 2002 6:29 PM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] Re: viewstate question
Assuming that a variable called 'dropDownValue' is
the value you obtained from the database, you would
do the following:
dropDownList.SelectedIndex =
dropDownList.Items.IndexOf(dropDownValue)
I don't have VS.NET up right now to verify, but I
think that syntax is good.
--- Original Message ---
From: Greg Partin <GPartin@c...>
To: "Website Programming with ASP.NET"
<aspdotnet_website_programming@p...>
Subject: [aspdotnet_website_programming] Re:
viewstate question
>I'm sorry, I guess I didn't explain myself clearly
enough. The user will be
>using drop down boxes to dynamically create a query
that runs a report. The
>values that I need to store are the values in the
drop down boxes. A week
>later (or whenever) I need to be able to re-
establish those drop-down boxes
>with the values that I stored from the original
query. In ASP I would do
>something like this:
>
>sql = "select drop_down_value from saved_report
where user_id = 52"
>
>rsDropDown = sql.execute()
>
>if rsDropDown("drop_down_value") =
current_drop_down_value then
> response.write("selected")
>end if
>
>But I have no idea how to do this in ASP.NET Does
this clear things up a
>little?
>
>thanks again,
>Greg
>
>-----Original Message-----
>From: TLAMOT@s...
[mailto:TLAMOT@s...]
>Sent: Friday, April 12, 2002 4:24 PM
>To: Website Programming with ASP.NET
>Subject: [aspdotnet_website_programming] Re:
viewstate question
>
>
>You would simply retrieve the value from the
database
>a week later (or whatever), and then set the value
of
>your text control.
>
>e.g.
>
>Dim test as String
>' ** retrieve data from the database into the test
>field
>txtReportName.Text = test
>
>After you do the above line, then ASP.NET will auto-
>populate your text control with that value.
>
>I hope this answers your question as I didn't quite
>understand what you were trying to accomplish.
>--- Original Message ---
>From: Greg Partin <GPartin@c...>
>To: "Website Programming with ASP.NET"
><aspdotnet_website_programming@p...>
>Subject: [aspdotnet_website_programming] Re:
>viewstate question
>
>>Thanks, that does clear things up a bit. But how
>can I use the 'text' from
>>the control to recreate the page, say, a week later
>if I store it in a
>>database? I could have a column called
>subject_dropdown_text and fill it
>>with whatever the user chose but then how do I use
>that value to recreate
>>the dropdown with the proper value selected?
>>
>>thanks again,
>>Greg
>>
>>-----Original Message-----
>>From: TLAMOT@s...
>[mailto:TLAMOT@s...]
>>Sent: Friday, April 12, 2002 1:13 PM
>>To: Website Programming with ASP.NET
>>Subject: [aspdotnet_website_programming] Re:
>viewstate question
>>
>>
>>I would avoid using the viewState entirely if you
>can.
>>ASP.NET re-constitutes the control states from the
>>viewstate state bag during each round trip,
>including
>>an onClick event. This means that you can just pull
>>the text from the control itself rather than the
bag.
>>
>>Therefore, you can just do this:
>>
>>Dim test as String
>>test = txtReportName.Text
>>
>>Hope this helps.
>>--- Original Message ---
>>From: Greg Partin <GPartin@c...>
>>To: "Website Programming with ASP.NET"
>><aspdotnet_website_programming@p...>
>>Subject: [aspdotnet_website_programming] viewstate
>>question
>>
>>>Hi folks,
>>>
>>>I'm trying to 'save' state information for a page
>in
>>a database for later
>>>retrieval. The reason behind this is for users to
>>be able to save specific
>>>reporting criteria. I'm having a little trouble
>>with the code. I have a
>>>textbox on a page called txtReportName. In my
>>codebehind page, I have a
>>>function that is called onclick. All I want to do
>>is store the state of
>>>txtReportName in a string and insert it into the
>>database. The following
>>>code does not work, test is never set to
anything.
>>Is the syntax incorrect?
>>>Am I not understanding how viewstate's statebag
>>works? The way I am
>>>imagining it is viewstate is a hashtable with the
>>control names and the
>>>state in the table.
>>>
>>>Dim test As String
>>>test = viewstate("txtReportName")
>>>
>>>Any help or suggestions would be appreciated.
>>>
>>>thanks,
>>>Greg
>>>
>>>to unsubscribe send a blank email to leave-
>>aspdotnet_website_programming-1076044R@p...
>>
>>
>>
>>
>>---
>>Incoming mail is certified Virus Free.
>>Checked by AVG anti-virus system
>(http://www.grisoft.com).
>>Version: 6.0.338 / Virus Database: 189 - Release
>Date: 3/14/2002
>>
>>
>>---
>>Outgoing mail is certified Virus Free.
>>Checked by AVG anti-virus system
>(http://www.grisoft.com).
>>Version: 6.0.346 / Virus Database: 194 - Release
>Date: 4/10/2002
>>
>>
>>to unsubscribe send a blank email to leave-
>aspdotnet_website_programming-1076044R@p...
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system
(http://www.grisoft.com).
>Version: 6.0.338 / Virus Database: 189 - Release
Date: 3/14/2002
>
>
>to unsubscribe send a blank email to leave-
aspdotnet_website_programming-1076044R@p...
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.338 / Virus Database: 189 - Release Date: 3/14/2002
|
|
 |