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">
<ig:CellEditing>
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="DynamicContentName" ReadOnly="true" />
</ColumnSettings>
</ig:CellEditing>
<ig:RowDeleting />
</Behaviors>
</ig:EditingCore>
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)
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")
uxDynamicContentsGrid.DataSource = uxDynamicContentsSource
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)
Hi Michael,
Thanks for your reply. I have been trying to get the Batch Updating to work in our scenario and have a couple of questions:
1. The grid is getting bound on every postback.
2. There is a dropdown list which allows users to select a view from the list. Selection of a view from the list changes the grouping of the WHDG.
3. When the users update data, the changes are persisted client side. When the user selects a new view from the list, the page load method updates the grouping of the WHDG by rebinding the grid. Only after this, the RowUpdating method is raised. The eventargs of the method indicates the correct row index, however, the new value is incorrect because it refers to the rows in the grid after it was rebound in the page load method.
Is there a way to fix this issue?
Hi Insula Group Pty Ltd,
I apologize for the delayed response. EnableDataViewState is not meant to be used in conjunction with Updating. We recommend keeping EnableDataViewState set to false when your users will need to update the grid. It sounds to me like you are looking for Batch Updating for keeping the data client side. Please see the following documentation for more information on this:
http://help.infragistics.com/NetAdvantage/ASPNET/2013.1/CLR4.0/?page=WebDataGrid_Batch_Updating_Enabling.html
You can also see a working sample of Batch Updating here:
http://ko.infragistics.com/products/aspnet/sample/data-grid/batch-updating
We are trying to understand why you need to persist the data on client side across postbacks. Are you referring to the same postback that is occurring when each row is updated, or is there some external postback being triggered? Batch Updating will eliminate the postback when the row is updated, so please let me know if this is something you are looking for.
Any updates on this.
We appreciate you taking the time to help us resolve this issue. As mentioned in my previous post:
1. The grid needs to maintain the changes until the 'Save' button is clicked. Currently, each row update raises a server event (to do some checks) which updates viewstate variables and the grid is then rebound to this view state variable. However, users are complaining that this is slow.
2. We have been trying to keep the changes on client side, however when a postback occurs the grid is rebound and the changes are lost.
If you could even just provide a sample with ability to persist changes made client side using EnableDataViewState = true and also the ability to switch to grouped view on dropdown list selection changed, it would help us a lot. We have a release in about 2 weeks and we are battling with this issue.
I am discussing this with my supervisor for further guidance on this issue.
If you have any further questions or concerns with this, please let me know and I will be glad to help.