Link to home
Start Free TrialLog in
Avatar of jazjef
jazjef

asked on

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

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.

Avatar of renjurdevan
renjurdevan
Flag of India image

The reason because the panel becomes null is, it may available only in edit mode!!

Ie Your panel is placed in editItemtemplate tag right?

Regards
Renju
Avatar of jazjef
jazjef

ASKER

The formview is always in edit mode and never exits, so it's not an edit mode problem..... its a visiblity-due-to-postback issue.
ASKER CERTIFIED SOLUTION
Avatar of jazjef
jazjef

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jazjef

ASKER

Dear sysadmin:

Once again, here is my previous post for my own solution to my own problem as listed above:

"I have solved my problem by developing a workaround via a design change. The problem no longer exists."

THIS QUESTION IS NO LONGER OPEN. PLEASE DO NOT NAG ME ABOUT IT. PLEASE READ THE FORUM POSTINGS BEFORE NAGGING THE MEMBERS ABOUT CLEANING UP THEIR QUESTIONS. I AM REQUESTING A REFUND OF POINTS ON THIS... THANK YOU.
Avatar of jazjef

ASKER

Dear sysadmin....AGAIN.... REQUESTING REFUND ON THIS QUESTION....... AGAIN.

Once again, here is my previous post for my own solution to my own problem as listed above:

"I have solved my problem by developing a workaround via a design change. The problem no longer exists."

THIS QUESTION IS NO LONGER OPEN. PLEASE DO NOT NAG ME ABOUT IT. PLEASE READ THE FORUM POSTINGS BEFORE NAGGING THE MEMBERS ABOUT CLEANING UP THEIR QUESTIONS. I AM REQUESTING A REFUND OF POINTS ON THIS... THANK YOU.