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
935
WHDG - EnableDataViewState issues
posted

Hi All,

I have a WHDG bound to a WebHierarchicalDataSource with a list of custom entities. The design on the grid is as follows:

                                                    <ig:WebHierarchicalDataGrid ID="uxDynamicContentsGrid" runat="server" Width="550px" Height="750px"

                                                        AutoGenerateBands="False" AutoGenerateColumns="False" EnableAJAX="false"

                                                        DataMember="DCDetails" Key="DCDetails" EnableDataViewState="false"

                                                        DataKeyFields="DynamicContentViewId"

                                                        GroupingSettings-ShowRemoveButton="False" StyleSetName="Office2007Silver"

                                                        GroupingSettings-GroupedRowTextMask="{1}" ShowHeader="False">

                                                        <EmptyRowsTemplate>There are no groups/ dynamic content assigned to the selected view.</EmptyRowsTemplate>

                                                        <GroupingSettings EnableColumnGrouping="True" GroupAreaVisibility="Hidden" ShowRemoveButton="False">

                                                            <RemoveButton AltText="Ungroup Column" />

                                                        </GroupingSettings>

                                                        <Behaviors>

                                                            <ig:Sorting Enabled="false"></ig:Sorting>

                                                            <ig:Activation>

                                                            </ig:Activation>

                                                            <ig:EditingCore AutoCRUD="False">

                                                                <Behaviors>

                                                                <ig:CellEditing>

                                                                        <ColumnSettings>

                                                                        <ig:EditingColumnSetting ColumnKey="DynamicContentName" ReadOnly="true" />

                                                                        </ColumnSettings>

                                                                    </ig:CellEditing>

                                                                    <ig:RowDeleting />

                                                                </Behaviors>

                                                            </ig:EditingCore>

                                                        </Behaviors>

The grid is bound on every postback (to resolve certain other issues we have). The loading of the grid is as follows:

        uxDynamicContentsGrid.Rows.Clear()

        uxDynamicContentsGrid.GroupingSettings.EnableColumnGrouping = DefaultableBoolean.False

        uxDynamicContentsGrid.GroupingSettings.GroupedColumns.Clear()

        uxDynamicContentsGrid.GroupingSettings.ColumnSettings.Clear()

        uxDynamicContentsSource.DataRelations.Clear()

        uxDynamicContentsSource.DataViews.Clear()

        uxDynamicContentsGrid.DataSource = Nothing

        uxDynamicContentsGrid.DataBind()

        Dim viewId As Integer = uxViewDropDown.SelectedValue

        If viewId > 0 Then

            contents = entityManager.GetContentsByEntityIdAndViewId(EntityId, viewId)

        Else

            contents = entityManager.GetContentsByEntityId(EntityId)

        End If

        ' Specify data views

        Dim dv As New Infragistics.Web.UI.DataSourceControls.DataView

        dv = New Infragistics.Web.UI.DataSourceControls.DataView

        dv.ID = "DCDetails"

        dv.DataSource = contents

        ' Add view to datasource

        uxDynamicContentsSource.DataViews.Add(dv)

        If viewId > 0 Then

            uxDynamicContentsGrid.GroupingSettings.EnableColumnGrouping = DefaultableBoolean.True

            ' A calculated property OrderedGroupName has been added which returns GroupOrder_ContentOrder_GroupName

            Dim setting As New GridControls.ColumnGroupingSetting

            setting.ColumnKey = "OrderedGroupName"

            setting.GroupComparer = New GroupNameComparer()

            uxDynamicContentsGrid.GroupingSettings.ColumnSettings.Add(setting)

            uxDynamicContentsGrid.GroupingSettings.GroupedColumns.Add("OrderedGroupName")

        End If

        uxDynamicContentsGrid.DataSource = uxDynamicContentsSource

        uxDynamicContentsGrid.DataBind()

 

THE ISSUE

1. WE are trying to avoid the binding of the grid on every postback. As per, other forum responses, we tried setting the EnableDAtaViewState property of the grid and binding the datasource only if not postback.

However, we are getting all sorts of errors, two of which are below: Does anyone have a working sample of WHDG with EnableDataViewState="true" ? Is there anything we are missing?

2. When RowUpdate event is fired, it causes additional column to appear and changes the heading of the grid. Does WHDG require the datasource to be bound on row update as well?

Thanks!

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.  Source : System.Web  Help link :   ParamName :   Data : System.Collections.ListDictionaryInternal  TargetSite : Void ValidateEvent(System.String, System.String)  Stack Trace :    at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)     at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)     at System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection)     at System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)     at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   

Multiple controls with the same ID 'it3_0' were found. FindControl requires that controls have unique IDs.  Source : System.Web  Help link :   ErrorCode : -2147467259  Data : System.Collections.ListDictionaryInternal  TargetSite : Void FillNamedControlsTable(System.Web.UI.Control, System.Web.UI.ControlCollection)  Stack Trace :    at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)     at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)     at System.Web.UI.Control.EnsureNamedControlsTable()     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)     at System.Web.UI.Page.FindControl(String id)     at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   

  • 935
    posted

    Hi All,

    An update, the error with the 'Multiple controls with same ID' is no longer happening. However, the invalid postback or callback argument error is happening after a couple of tree selections i.e. we can select two or three entities in the treeview properly, but after that when a tree selection is made, we start getting the following error for both dropdown list and checkbox controls"

    We would appreciate any feedback from the Infragistics team or anyone else who has managed to successfully bind the grid only if not postback and use data view state all other times.

    Thanks,

    Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.  Source : System.Web  Help link :   ParamName :   Data : System.Collections.ListDictionaryInternal  TargetSite : Void ValidateEvent(System.String, System.String)  Stack Trace :    at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)     at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)     at System.Web.UI.WebControls.DropDownList.LoadPostData(String postDataKey, NameValueCollection postCollection)     at System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)     at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

     

    • 18204
      Offline posted in reply to Insula Group Pty Ltd

      Hi Insula Group Pty Ltd,

       

      Thank you for posting in our forums!

      I am glad to hear you were able to resolve the issue with multiple IDs occurring on the page.

      If your concern with binding to the WebDataGrid on each postback is with accessing your database each time, one alternative is to store the DataSource in a Session variable and use that on each postback. 

      Setting EnableDataViewState to true is all that is required.  I am unsure of what may cause that error and I will need a little more time to look into this issue.

      For the issue where additional columns are appearing, are you dynamically creating columns in code behind elsewhere that you have not posted here?

      I will have another update for you by Friday.  If you have any further questions or concerns with this, please let me know.

      • 935
        posted in reply to Michael Peterson

        Thanks Michael.

        I think we now have enough information to come up with a solution for this problem. I will contact you if we have any further questions.

        Thanks for all your assistance.

         

         

        • 25665
          Offline posted in reply to Insula Group Pty Ltd

          Hello Insula Group Pty Ltd,

          Thank you for the update. There isn’t a specific rows updated finished event. What we recommend if you want to change the data in the grid after making update is to keep track of the number of rows that are going to be updated and change the data after the last one has been updated. This should be the case if you have batch updating enabled as 1 postback will occur for all the updates. If you have a postback for each row modified by having batch updating set to false and activation enabled you should just be able to do your data change at the end of the RowUpdating event.

          Please let me know if you have any further questions concerning this matter.

          Sincerely, Mike P. Developer Support Engineer II Infragistics, Inc. www.infragistics.com

          • 935
            posted in reply to Michael Peterson

            Hi Michael,

            Thanks for your help.

            "With the third question if selecting a new view changes the data that will be in your grid you will want to wait until after the RowUpdating event has finished running for the number of updated rows before assigning the new data to the grid."

            Yes, when the selected 'view' changes, the data in the grid should change. If we were to delay the change to data source until after all rows are batch updated, is there an event that is fired once all the rows are updated in the batch?

            Thanks!

            • 25665
              Offline posted in reply to Insula Group Pty Ltd

              Hello Insula Group Pty Ltd,

              Thank you for the update. For your first question it is expected for the grid to have the data to setback to it on postback. For example to set the data back to the grid without calling databind on postback you can do something like the following:

              if (Session["GridData"] == null)         {             Session["GridData"] = GetDepartments();             WebDataGrid1.DataSource = Session["GridData"];             WebDataGrid1.DataBind();         }         else         {             WebDataGrid1.DataSource = Session["GridData"];         }

              For your second question what do you mean by view? Do you handle any of the selection events? Or preform any actions on selection from the dropdown? Does the view changed the data in the grid?

              With the third question if selecting a new view changes the data that will be in your grid you will want to wait until after the RowUpdating event has finished running for the number of updated rows before assigning the new data to the grid.

              Sincerely, Mike P. Developer Support Engineer II Infragistics, Inc. www.infragistics.com

              • 935
                posted in reply to Insula Group Pty Ltd

                Hi Michael,

                We would appreciate your assistance with regards to this request.

                Thanks.