Jump to content
Software FX Community

'Failed to load viewstate' error after deleting the last item from the grid


Recommended Posts

I have a grid that has a Delete Item button in each row. This works well except when I delete the last item in the grid and then click a button on the page I get following error:

"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request."

Any idea what's causing this?

Link to comment
Share on other sites

I have two different gridfx controls on the page and they both exhibit this problem.

I use the design time delete functionality, however I do have an item deleted handler for each grid that databinds the grid. For some reason I had to do this, without the databind I get the following error on delete:

 "Index out of range. Must be non-negative and less then the size of the collection.

Parameter name: Index"

With the databind in the item deleted handler the delete works fine, but upon the delete of the last item I get an error as described before.

The "failed to load viewstate" error occurs after the page load event, but before any of the other events I use (databinding, databound, rendering) are called.

Link to comment
Share on other sites

I tested locally and couldn't reproduce.  Could you do me a favor and send me the following (just for one of the grids if you want...or both):

1) The grid's markup

2) The grid related code behing

3) The version of Grid FX you have.  To find this, open the smart tag in Visual Studio and go to About Grid FX

After this, I can better assist you.  Thanks for using Grid FX.  This will be resolved and you'll be up and running soon.


Link to comment
Share on other sites

My current version is 1.0.2994.21460

The only code pertaining to the grid is:

Protected Sub Grid4_ItemDeleted(ByVal sender as object, ByVal e As GridFx.WebForms.GridItemDeletedEventArgs)

Dim grid4 as GridFX.WebForms.Grid = sender


End Sub

I also set page.maintainscrollpositiononpostback = true in pageload, not sure if this has any effect on the grid.

As I said, if I remove the databind I get the index out of bounds error, if I leave it in I get the load state error after deleting the last item and clicking anything that causes a callback.

Here's the markup for this grid:

<GridFX:Grid ID="Grid4" runat="server" DataSourceID="SqlDataSource5" Motif="Elegant" Palette="Professional" OnItemDeleted="grid4_itemdeleted" Width="330px" >   <DataFields>   <GridFX:NumberField DataPath="uid" IsKey="True" ReadOnly="True">   </GridFX:NumberField>   <GridFX:NumberField DataPath="threshold" ReadOnly="True">   </GridFX:NumberField>   <GridFX:LookupField DataPath="PrRng_ID" Title="Metric" UniqueID="PrRng_ID1" ReadOnly="True">   <LookupDataSource ControlID="SqlDataSource6" TextDataPath="ProcessType" ValueDataPath="ID" />   <Input ControlType="DropDown" />   <Grouping>   <IntervalMarkup>   <GridFX:DistinctValuesInterval IncludeFieldTitleInTitle="False" Title="{Value} " />   </IntervalMarkup>   </Grouping>   </GridFX:LookupField>   <GridFX:LookupField Title="Notification Type" UniqueID="Notification Type" DataPath="threshold" ReadOnly="True">   <LookupItems>   <GridFX:LookupItem Text="On Any Threshold Change" Value="0" />   <GridFX:LookupItem Text="<FONT COLOR='GREEN'>On Green (Meets Standard)</FONT>" Value="1" />   <GridFX:LookupItem Text="<FONT COLOR='YELLOW'>On Yellow (Marginal)</FONT>" Value="2" />   <GridFX:LookupItem Text="<FONT COLOR='RED'>On Red (Substandard)</FONT>" Value="3" />   <GridFX:LookupItem Text="<FONT COLOR='BROWN'>On Brown (No Data Expected)</FONT>" Value="4" />   <GridFX:LookupItem Text="On Black (Unreported)" Value="5" />   <GridFX:LookupItem Text="Always" Value="9" />   </LookupItems>   <Input ControlType="DropDown" />   </GridFX:LookupField>   <GridFX:TextField DataPath="location_name" ReadOnly="True" Title="Location">   <Format>   <DigitalPanel Height="50px" Width="200px">   </DigitalPanel>   </Format>   </GridFX:TextField>   </DataFields>   <Border Type="None" />   <ToolBar Visible="False">   </ToolBar>   <FloatingBar Enabled="False" />   <Columns>   <GridFX:FieldColumn Field="location_name">   </GridFX:FieldColumn>   <GridFX:FieldColumn Field="Notification Type">   </GridFX:FieldColumn>   <GridFX:TemplateColumn Style-Header-Bold="False" Style-Header-FontSize="X-Small"   Style-Header-ForeColor="ControlText" Style-Header-Italic="False" Style-Header-Underline="False" Width="80px">   <ItemTemplate>   <GridFX:CommandButton ID="UnSubButton" runat="server" ButtonType="Push" Command="DeleteItem"   Font-Size="X-Small" Text="Unsubscribe" />   </ItemTemplate>   </GridFX:TemplateColumn>   </Columns>   <Grouping Enabled="True">   <RootLevel Expanded="True" Field="PrRng_ID1">   </RootLevel>   </Grouping>   <Paging Enabled="False">   </Paging>   <ItemStyles>   <MainStyle FontFamily="Verdana" ForeColor="Black" />   </ItemStyles>   <EmptyData Description="Select a subscription and click the Subscribe botton" Heading="No {DataNoun.PluralTitle} Found">   <Image Visible="False" />   </EmptyData>   <DataNoun PluralLower="alert subscriptions" PluralTitle="Alert Subscriptions" SingularLower="alert subscription"   SingularTitle="Alert Subscription" />   <Filtering Enabled="False">   </Filtering>   <Selection Enabled="False" />   </GridFX:Grid>

Please let me know if you need any further information and thanks in advance for your efforts to solve this.


Link to comment
Share on other sites

  • 2 weeks later...



I am sorry for the lack of updates. Could you please send an email directly to supportATsoftwarefxDOTcom. Simply reference this post. That way we will have  ticket open and you will get a direct line of communication with our support team while we continue troubleshooting the issue.

Once we solve your issue, we will post the solution on the forum.


Link to comment
Share on other sites

  • 4 weeks later...

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.

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.

  • Create New...