troubleshooting Question

How do I persist visibility of a panel control across postbacks?

Avatar of jazjef
jazjef asked on
.NET ProgrammingASP.NETMicrosoft SQL Server 2005
5 Comments1 Solution628 ViewsLast Modified:
My tools:  Visual Web Developer, SQL Server 2005, VB.net back coding

I have a formview control that defaults to 'edit' mode when the form starts.... on formview1 there is button1 that makes panel1 become visible. On panel1 there is radiobuttonlist1 that has 2 options; NULL and A....radiobuttonlist1 is bound to an SQL table datafield that initially has no value (NULL).....so, the default selection for the radiobuttonlist is NULL. The radiobuttonlist1 has 'autopostback' = True.

So, after the button click, panel1 becomes visible with NULL already pre-selected....if the user selects A then the postback occurs making textbox1 visible where they are to enter some data.

Here is the code in RadioButtonList1 selectedindexchanged:

    Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

            FormView1.FindControl("Panel1").Visible = True

    End Sub
   
HERE IS MY PROBLEM:
If I select option A from radiobuttonlist1, no problem.... option A gets selected and the textbox becomes visible.... BUT, if I change my mind and try to re-select the NULL option , the entire panel disappears. Why does it do this? According to the sub, any index change of the radiobuttonlist should persist visibility of panel1.

No matter how this radiobuttonlist is set up and no matter what the default value is that populates it from the SQL table, if I make an attempt to return to the radiobuttonlist default value (cause a second postback) the panel disappears despite the code that tells it to be visible.....

Any help is appreciated....thanks.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros