I have another page that is a search page with filters on the top and they retain their viewstate even though the user table below displays different information. But, why do you think nothing is retaining it's viewstate. If it is the only solution then I guess it has to be done. I do not create the panel in the background and I don't really have the time to recreate the panel in the background. It's just the panel made for each user with different information in it depending on the user.īelow is the template field I have that houses the panel, it is under the TR with the ID of "DetailsPane" String panelState = (hiddenFieldRef.Value = "none") ? "none" : "block" īuttonRef.Text = (panelState = "none") ? "Show Panel" : "Hide Panel" PanelRef.ID = string.Format("Panel_') ", panelRef.ClientID, hiddenFieldRef.ClientID) ī("onclick", clickHandler) If ((placeHolderRef != null) & (buttonRef != null) & (hiddenFieldRef != null)) HiddenField hiddenFieldRef = (HiddenField)gridRow.FindControl("HiddenField1") PlaceHolder placeHolderRef = (PlaceHolder)gridRow.FindControl("PlaceHolder1") īutton buttonRef = (Button)gridRow.FindControl("Button1") This is an example using jQuerys show(), hide(), and toggle() methods to change the visibility of elements on the page. Protected void DataGrid1_PreRender(object sender, EventArgs e)įor (int i=0 i< i++)ĭataGridItem gridRow = DataGrid1.Items I'm not sure why, or how for that matter, you are creating dynamic Panels in a DataGrid in the PreRender page event, but the best way would be to handle the Grid's PreRender event. = (panelStateRef.value = 'none') ? 'none' : 'block'
Var buttonRef = document.getElementById('panelButton')
#Showhide javascript code
Below is the Javascript code that we will add the the Head section of the page. Basically this means that we can use this one function to show or hide more than one Div on the same page. We will pass the ID attribute of the Div to the function. Var panelRef = document.getElementById('') In order to show the div we will need to add a Javascript function. PanelStateRef.value = īuttonRef.value = ( = 'none') ? 'Show Panel' : 'Hide Panel' Var panelStateRef = document.getElementById('')