Maintaining my original value through postbacks and Radio Button events

I have a Radio Button SelectedIndexChanged event that adds 30% to a price if the relevant radio button ("Yes") is clicked.

However, if the person clicks the other radio button ("No") I want the price to revert back to the orginal price.

I cant seem to find a way to store the original price in the vewstate. The method below doesnt work properly as the viewstate takes the price from the actual textbox control (and this gets updated and increased everytime the user selects "Yes" in the Radio Button control. I need to store the price in the view state just once when the method is first run. I guess I need to use some kind of "counter" device that stores the number of times the Radio button has been selected.

    Public Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged

        ViewState("OriginalPrice") = lblPrice.Text

        If RadioButtonList1.SelectedItem.Text = "Yes" Then
            lblPrice.Text = FormatCurrency(CInt(lblPrice.Text) + ((CInt(lblPrice.Text) / 100) * 30), 2)
            lblPrice.Text = FormatCurrency(ViewState("OriginalPrice"))
        End If

    End Sub

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason ScolaroCommented:
Could something like this work for you?

If ViewState("OriginalPrice") Is Nothing Then ViewState("OriginalPrice") = lblPrice.Text

Then it will only fill the ViewState, OriginalPrice, if it hasn't already been filled in.

-- Jason

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
g-spotAuthor Commented:
Thanks Jason. Thats perfect.

I seem to be trying to make things more difficult for myself and am missing the obvious answers!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.