Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
WebHierarchicalDataGrid -Failed to Load ViewState When Deleting the Row.
posted

We are using  WebHierarchicalDataGrid (Version -13.1.20131.2069)

When i am deleting the 2 rows continuously i am not received any issues when i am deleting the next row  continuously (3rd) i have received the following issue.

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.


Here i have mentioned code snippets.

  <script type="text/javascript" id="igClientScript1">
        // Redirect to location page.
        function whdgVendor_ContainerGrid_DoubleClick(sender, eventArgs) {
            if (sender._level != 0) {
                return false;
            }
            else {
                var row = eventArgs.get_item().get_row().get_dataKey()[0];
                __doPostBack('btnRedirect', row);
            }
        }

        // Confirmation dialog for deleting the branch.
        function ConfirmDeletion(sender, eventArgs) {
            // Open a dialog to use asking for a yes/no about deletion
            var continueDelete = confirm("Are you sure you want to delete this record?");
            // if end-user says no, cancel the delete action
            if (!continueDelete)
                eventArgs.set_cancel(true);
        }

    </script>


   <ig:WebHierarchicalDataGrid ID="whdgVendor" runat="server" Width="100%"
            EnableAjax="False" EnableAjaxViewState="False" EnableDataViewState="True"
            InitialDataBindDepth="1" AutoGenerateColumns="False" DataKeyFields="VendorID"
            DataMember="Vendor" AutoGenerateBands="False"  OnRowsDeleting ="gridVendorList_RowsDeleting"
            onpageindexchanged="grdVendorList_PageIndexChanged"
            oncolumnsorted="grdVendorList_ColumnSorted"
            ondatafiltering="grdVendorList_DataFiltering"
            oninitializerow="whdgVendor_InitializeRow" Key="VendorID" EnableViewState="True">
            <Bands>
                <ig:Band AutoGenerateColumns="False" DataKeyFields="VendorContactID" Key="VendorContactID"
                    DataMember="VendorContacts" Width="100%" Height="100%"
                    onpageindexchanged="grdVendorList_PageIndexChanged"
                    oncolumnsorted="grdVendorList_ColumnSorted"
                    ondatafiltering="grdVendorList_DataFiltering">
                    <Columns>
                        <ig:BoundDataField DataFieldName="ContactName" Key="ContactName">
                          <Header Text="Contact name"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="DepartmentID" Hidden="True" Key="DepartmentID">
                          <Header Text="DepartmentID"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="DepartmentName" Key="DepartmentName">
                          <Header Text="Department"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="ContactNumber" Key="ContactNumber">
                         <Header Text="Contact no"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="EmailID" Key="EmailID">
                         <Header Text="Email"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="ARContactName" Key="ARContactName">
                        <Header Text="ARContact name"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="ARContactNumber" Key="ARContactNumber">
                         <Header Text="ARContact number"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="VendorContactID" Hidden="True"
                            Key="VendorContactID">
                         <Header Text="VendorContactID"></Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="VendorID" Hidden="True" Key="VendorID">
                          <Header Text="VendorID"></Header>
                        </ig:BoundDataField>
                    </Columns>
                        <Behaviors>
                 <ig:Sorting>
                 </ig:Sorting>
                 <ig:Paging>
                 </ig:Paging>
                 <ig:Filtering>
                 </ig:Filtering>
            </Behaviors>
                </ig:Band>
            </Bands>
             <ClientEvents DoubleClick="whdgVendor_ContainerGrid_DoubleClick" />
            <Columns>
                <ig:BoundDataField DataFieldName="VendorID" Hidden="True" Key="VendorID">
                <Header Text="VendorID"></Header>
                </ig:BoundDataField>   
                <ig:BoundDataField DataFieldName="VendorName" Key="VendorName">
                 <Header Text="Name"></Header>
                </ig:BoundDataField>
                  <ig:BoundDataField DataFieldName="Address" Key="Address">
                <Header Text="Address"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="City" Key="City">
                <Header Text="City"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="State" Key="State">
                <Header Text="State"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="PhoneNumber" Key="PhoneNumber">
                <Header Text="Contact no"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="AlternatePhoneNo" Key="AlternatePhoneNo">
                 <Header Text="Alternate no"></Header>
                </ig:BoundDataField>
                 <ig:BoundDataField DataFieldName="Fax" Key="Fax">
                 <Header Text="Fax"></Header>
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="Notes" Key="Notes">
                <Header Text="Notes"></Header>
                </ig:BoundDataField>
            </Columns>
                     <Behaviors>
                 <ig:Activation>
                </ig:Activation>
                 <ig:EditingCore AutoCRUD="False">
                  <EditingClientEvents RowsDeleting="ConfirmDeletion"/>
                    <Behaviors>
                        <ig:RowDeleting />
                    </Behaviors>
                </ig:EditingCore>
                <ig:Selection CellClickAction="Row" RowSelectType="Single">
                </ig:Selection>
                <ig:RowSelectors>
                </ig:RowSelectors>
                 <ig:Sorting>
                 </ig:Sorting>
                 <ig:Paging>                 
                 </ig:Paging>
                 <ig:Filtering>
                 </ig:Filtering>
            </Behaviors>
            <EmptyRowsTemplate>
                        <div style="text-align: center;">
                           No records found
                        </div>
                    </EmptyRowsTemplate>
        </ig:WebHierarchicalDataGrid>

how to handle this issue .please kindly reply me.

Thanks & Regards,

P.Narayanan.






Parents
No Data
Reply
  • 5
    posted

    Set EnableViewState="false" on each control inside each template field; e.g.

    <ig:WebHierarchicalDataGrid runat="server" ID="hdg" DataSourceID="hds" DataKeyFields="ID" OnInitializeRow="hdg_InitializeRow">
      <Columns>
        <ig:TemplateDataField Key="ID" Text="Relationship ID">
          <ItemTemplate>
            <asp:Label runat="server" ID="lblID" EnableViewState="false" />
          </ItemTemplate>
        </ig:TemplateDataField>
        <ig:TemplateDataField Key="Add">
          <ItemTemplate>
            <asp:Button runat="server" ID="btn" Text="Add" CommandName="Add" EnableViewState="false" />
          </ItemTemplate>
        </ig:TemplateDataField>

      </Columns>

      ...

      <Bands>...</Bands>

      ...

      <Behaviors>...</Behaviors>

      ...

    </ig:WebHierarchicalDataGrid>

Children
No Data