Welcome Guest Search | Active Topics | Sign In | Register

Clear ViewState in DataGrid inside modal ie window Options
Darrell Reinke
Posted: Friday, July 31, 2009 9:59:18 AM
Rank: Advanced Member
Groups: Member

Joined: 7/18/2008
Posts: 76
Good morning,

I have been researching this issue and have not been able to figure out the solution and was wondering if you could shed some light on the correct settings for your datagrid.

I have a main asp.net page that opens via javascript a modal (using window.showModalDialog) .aspx page. I perform the necessary database updates from the modal window and have verified that the changes to the DB have been commited and the datagrid reflects the changes, etc. The datagrid is contained inside a callback panel. If I close out the modal window and then go back into the modal window the datagrid reverts back to the original dataset and does not reflect the new changes to the database. I have debugged the code and it is correctly executing

Code: Visual Basic.NET
Dim dsPhones As New DataSet
      dsPhones = PropertyInfo.getPropertyPhones(asPropertyID)

      If dsPhones.Tables(0).Rows.Count >= 1 Then

         Dim drPropertyInfo As DataRow = dsPhones.Tables(0).Rows(0)

         lblProperty.Text = "Phone Numbers for " + drPropertyInfo.Item("prop_nm").ToString.Trim

         grdPhones.Items.Clear()
         grdPhones.DataSource = dsPhones
         grdPhones.DataBind()
      Else
         lblProperty.Text = "Phone Numbers have not been assigned to this Property."
      End If


I have tried clearing the viewstate for the modal aspx page, but that does not seem to work. I have traced the viewstate and found that the viewstate for a modal window is contained inside the main window that opened the modal so clearing out the viewstate at the modal window does not have any affect on the datagrid. I know the datagrid is working correctly because if I open the window as a popup (using window.open) via javascript, the datagrid refreshes correctly everytime.

I have changed the javascript code to use the window.open where it makes sense, but there are a couple of instances where I need to use the window.showModalDialog.

Any suggestions would be greatly appreciated.

eo_support
Posted: Friday, July 31, 2009 10:20:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Your code looks fine to us and it does not appear to have anything to do with view state. It is more likely to a caching issue. I would suggest you to turn off caching and see if that works for you.

Thanks!
Darrell Reinke
Posted: Friday, July 31, 2009 12:17:50 PM
Rank: Advanced Member
Groups: Member

Joined: 7/18/2008
Posts: 76
It worked!!!! It appeared to be caching the page at the server level because initiating the following in the Page_Load has worked.

Code: Visual Basic.NET
'Turn Off Caching at the Server Level for this page.
      Response.Cache.SetCacheability(HttpCacheability.NoCache)


Curious.... I know you can turn off caching at the browser level as well, but I really don't want to go that route. Do you think that is necessary since the server side "No Cache" option is working?

Thank you.
eo_support
Posted: Friday, July 31, 2009 12:23:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
No. It's not necessary to turn off caching at the browser level not only because the browser supposes to honor the settings you passed down from the server, but also because you have not physical control over user's browser.
Darrell Reinke
Posted: Friday, July 31, 2009 12:32:29 PM
Rank: Advanced Member
Groups: Member

Joined: 7/18/2008
Posts: 76
Thank you for your time this morning! Once again, great support.
eo_support
Posted: Friday, July 31, 2009 12:57:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You are very welcome. Glad to hear that you like our product and service.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.