Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two pannels in .aspx page i.e panel1 and panel2;
i hav set the visibility property to false at page load for both of the pannels ,

now at pannel2 i have a textbox a button and a grid,

now i wrote select qyery at button clik that select the values from table(of databse) where a column equal to a value i have entered in a text box ... and view the results in a grid
i placed jst aftr the button ...

now the problem is that when i clik the button the page has to post back to show the results in grid .. but at page load i set the poperty of pannel visibility to false , so that i cant see my result in grid ..

help me guyz .. what can i do to solve this situation ???
Posted

Something along the lines of:

C#
if (!IsPostback)
{
    Panel.Visible = 
        Panel2.Visible = false;
}

// logic to set one or the other panel to visible.
 
Share this answer
 
Comments
Rahul Rajat Singh 28-Jun-12 2:34am    
good answer. +5.
When page get postback all the controls get re-initialise. if you dont want to re-initialise use IsPostBack

C#
If(!IsPostBack)
{
       Panel1.Visible=false;
       Panel2.Visible=false;
}

Thanks
Ashish
 
Share this answer
 
v3
Comments
Rahul Rajat Singh 28-Jun-12 2:33am    
good answer. +5.
Rahul Rajat Singh 28-Jun-12 2:35am    
If you need to avoid postback even then too then An alternative to this solution (or which can be used in conjunction of this solution) is to move the panel2 inside an updaetpanel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900