Jump to content
Software FX Community

Grid state


vaioklm
 Share

Recommended Posts

The Grid appears to be losing state when something else on the page causes a postback.  For instance, I drop a grid and a button on the page and populate the grid with enough data to cause it to page.  I go to the 3rd page of the grid.  I then click the button which causes the page to postback.  My grid has returned to page 1 after the postback.  I've also seen it lose my sort and my groupings.  This seems to happen whether I drop the Grid directly onto the page through the Designer or put it in a custom control.  I've tried setting EnableViewState = True, but this seemed to have no effect.  Is there some other property I need to set?

 Thanks

Link to comment
Share on other sites

Odd.  I tested a similar example just now and it works fine.  The way it works is this: during callbacks, the grid's state is stored in a hidden field.  This is because the ViewState hidden field cannot be partially updated, and updating the entire thing would be wasteful.  Once a postback is done, the grid will check for the existence of that hidden field, and if the field is present, will load its state from that as opposed to the ViewState's big hidden field.  If it doesn't, it'll give results like you describe.

Troubleshooting this might be tough.  If setting EnableViewState to true isn't working, maybe there is some issue with that hidden field.  Could you answer these questions:  do you use the default hidden field for ViewState (hidden field called _VIEWSTATE)?  do you have FireBug or IE development toolbar installed? 

Link to comment
Share on other sites

In the most basic test that I've done, I do not add anything to ViewState.  In our more complex custom controls, we do store some property values in ViewState.  I do have IE Dev Toolbar installed.  If it helps, here is the ASPX page I've used to test this.  It is very basic with no code behind.

 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<%

@ Register Assembly="ChartFX.WebForms" Namespace="ChartFX.WebForms" TagPrefix="chartfx7" %><%@ Register Assembly="GridFX.WebForms" Namespace="GridFX.WebForms" TagPrefix="GridFX" %>

<%

@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml" >

<

head runat="server"><title>Untitled Page</title>

</

head>

<

body>

<form id="form1" runat="server">

<div>

 

<asp:Button ID="Button1" runat="server" Text="Button" /></div>

<GridFX:Grid ID="Grid1" runat="server" DataSourceID="SqlDataSource1">

<Columns>

<GridFX:FieldColumn Field="report_name">

</GridFX:FieldColumn>

<GridFX:FieldColumn Field="report_desc">

</GridFX:FieldColumn>

<GridFX:FieldColumn Field="report_type">

</GridFX:FieldColumn>

<GridFX:FieldColumn Field="report_id">

</GridFX:FieldColumn>

<GridFX:FieldColumn Field="db_table_id">

</GridFX:FieldColumn>

</Columns>

<DataFields>

<GridFX:TextField DataPath="report_name">

<Format>

<DigitalPanel Height="50px" Width="200px">

</DigitalPanel>

</Format>

</GridFX:TextField>

<GridFX:TextField DataPath="report_desc">

<Format>

<DigitalPanel Height="50px" Width="200px">

</DigitalPanel>

</Format>

</GridFX:TextField>

<GridFX:NumberField DataPath="report_type">

</GridFX:NumberField>

<GridFX:NumberField DataPath="report_id" ReadOnly="True">

</GridFX:NumberField>

<GridFX:NumberField DataPath="db_table_id">

</GridFX:NumberField>

</DataFields>

</GridFX:Grid>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Par80ConnectionString2 %>"

SelectCommand="SELECT * FROM [TWR115_REPORT_DESC]"></asp:SqlDataSource></form>

</

body>

</

html>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...