Greetings,
I have a grid that has only three entries in it with three columns, with 2 visible and the 3rd hidden. One of my columns is a template that has a label in the Item Template, and a textbox and validator to validate the textbox in the Edit Template. I have set the grid up to use validation, and I am only doing editing for this grid. Here is the code for the grid.
Anyways, when I start editing, the validator functions properly. Then when I try to save what is in the textbox when something is in it, I get this 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.
There are no controls being added or taken off, and for the life of me, I can't figure out what it's talking about. If someone could help me, I'd be very appreciative. Thanks.
~ Chad
I have a grid that has only three entries in it with three columns, with 2 visible and the 3rd hidden. One of my columns is a template that has a label in the Item Template, and a textbox and validator to validate the textbox in the Edit Template. I have set the grid up to use validation, and I am only doing editing for this grid. Here is the code for the grid.
<telerik:RadGrid ID="rgdStatusList" runat="server" AllowPaging="True" AllowSorting="True" |
AutoGenerateColumns="False" DataSourceID="odsGetStatusList" GridLines="None" |
OnNeedDataSource="rgdStatusList_NeedDataSource" ShowGroupPanel="false" |
OnItemCommand="rgdStatusList_ItemCommand" ShowStatusBar="True" |
AllowMultiRowSelection="true" PageSize="30" OnItemDataBound="rgdStatusList_ItemDataBound" |
onprerender="rgdStatusList_PreRender" OnInsertCommand="rgdStatusList_InsertCommand" Width="275px" |
OnPageIndexChanged="rgdStatusList_PageIndexChanged" OnDeleteCommand="rgdStatusList_DeleteCommand"> |
<ValidationSettings EnableValidation="true" /> |
<MasterTableView DataKeyNames="StatusID" DataSourceID="odsGetStatusList" CommandItemDisplay="Top" |
EditMode="InPlace"> |
<PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" /> |
<CommandItemTemplate> |
<telerik:RadToolBar ID="rtbToolBar" OnButtonClick="rtbToolBar_ButtonClick" runat="server" |
OnClientButtonClicking="onToolBarClientButtonClicking"> |
<Items> |
<telerik:RadToolBarButton Text="Add Status" SkinID="AddBtn" CommandName="InitInsert" ToolTip="Add Status Code" |
Visible='<%# !rgdStatusList.MasterTableView.IsItemInserted %>'> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Save Status" SkinID="AddBtn" CommandName="PerformInsert" ToolTip="Save Status" |
Visible='<%# rgdStatusList.MasterTableView.IsItemInserted %>' ValidationGroup="validate"> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Cancel" SkinID="CancelBtn" CommandName="CancelAll" ToolTip="Cancel" |
Visible='<%# rgdStatusList.MasterTableView.IsItemInserted %>'> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Delete Status" SkinID="DeleteBtn" CommandName="DeleteSelected" ToolTip="Delete Status Code" |
Visible='<%# !rgdStatusList.MasterTableView.IsItemInserted %>'> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Set Defaults" SkinID="SetDefaultsBtn" CommandName="SetDefaults" ToolTip="Set Defaults"> |
</telerik:RadToolBarButton> |
</Items> |
</telerik:RadToolBar> |
</CommandItemTemplate> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="StatusID" DataType="System.Int32" |
HeaderText="Status ID" SortExpression="StatusID" UniqueName="StatusID" ReadOnly="true" |
Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn DataField="StatusDescription" HeaderText="Status Name" |
SortExpression="StatusDescription" UniqueName="StatusDescription" EditFormColumnIndex="1"> |
<ItemTemplate> |
<asp:Label ID="lblStatusDesc" runat="server" |
Text='<%# DataBinder.Eval(Container, "DataItem.StatusDescription")%>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadTextBox ID="txtStatusDesc" runat="server" Text="" Width="200" MaxLength="26"> |
</telerik:RadTextBox> |
<br /> |
<asp:RequiredFieldValidator ID="rfvStatusDesc" runat="server" ControlToValidate="txtStatusDesc" |
ErrorMessage="You cannot have a blank Status Description." SetFocusOnError="true" |
ValidationGroup="validate" Display="Dynamic"> |
</asp:RequiredFieldValidator> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridTemplateColumn UniqueName="Active" DataField="Active" SortExpression="Active" |
HeaderText="Type" EditFormColumnIndex="1"> |
<ItemTemplate> |
<asp:Label ID="lblStatusType" runat="server" Text='<%# TypeStatus(DataBinder.Eval(Container, "DataItem.Active"))%>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<asp:CheckBox ID="chkActive" runat="server" ToolTip="Click to set this Status to an Active Type" /> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
<EditFormSettings ColumnNumber="2"> |
</EditFormSettings> |
</MasterTableView> |
<ClientSettings> |
<Selecting AllowRowSelect="true" /> |
</ClientSettings> |
<FilterMenu EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
<StatusBarSettings ReadyText="Ready" /> |
<ValidationSettings CommandsToValidate="PerformInsert" /> |
</telerik:RadGrid> |
Anyways, when I start editing, the validator functions properly. Then when I try to save what is in the textbox when something is in it, I get this 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.
There are no controls being added or taken off, and for the life of me, I can't figure out what it's talking about. If someone could help me, I'd be very appreciative. Thanks.
~ Chad