Hello, I have a little problem in a pretty straight forward scenario:
A WebHierarchicalDataGrid is filled with data from a DataSet on every PageLoad event with the following settings
- DataViewState is disable
- ViewState enabled (inherit)
- AutoCrud disabled
- BatchUpdate enabled
- DataSourceId is not set
Like I said, in the end of PageLoad, my BindGrid method is called
Protected Sub BindGrid()
Dim ds As DataSet = New DataSet
ds.Tables.Add(GetData(ddlEmployee.SelectedValue))
WebHierarchicalDataGrid1.DataSource = ds
WebHierarchicalDataGrid1.DataBind()
End Sub
Now, when update data in the grid, I manually update the database inside the RowUpdating event by calling a stored procedure.
The problem is - after all the rows have been updated and the page reloads, I still get the old values. Only if I refresh the page again, then I see the new values. So it seems to me, that when pressing the save button, the PageLoad is called, loading the still not updated, old values from the database to the grid, then the rows are updated in the database, but the grid shows the data that was load before the update.
What can I do. I cannot find a event that is called after all the rows have been updated so that I could rebind the grid to the updated datasource. Also, setting the DataViewState does not work, because it tells me that the datasource has no primary key. I would prefer a way without DataViewState though.
Thanks a lot, Kevin
Hello Kevin,
Thank you for the information provided. However I was not able to reproduce this behavior. I will highly appreciate if you could send me a working sample so as to experience the issue you are facing.
Hi Hristo, thanks for your help. Unfortunately, setting enableAjax to false and calling DataBind() in the rowUpdating event didn't resolve the problem.
Protected Sub WebHierarchicalDataGrid1_RowUpdating(sender As Object, e As Infragistics.Web.UI.GridControls.RowUpdatingEventArgs) Handles WebHierarchicalDataGrid1.RowUpdating
For i As Integer = 0 To e.OldValues.Count - 1
Dim key As String = e.OldValues.Keys(i)
Dim oldValue As String = e.OldValues.Values(i)
Dim newValue As String = e.Values(key)
If (oldValue <> newValue) Then
Dim period As String = e.Row.Items.FindItemByKey(key).Column.Header.Text
Dim decimalValue As Nullable(Of Decimal)
If newValue = 0 Then
decimalValue = Nothing
Else
decimalValue = newValue
End If
employeeTableAdapter.UpdateValues(e.Row.Items(0).Value, e.Row.Items(1).Value, e.Row.Items(3).Value, CUInt(period), decimalValue)
Next
And here the code of my WebHierarchicalDataGrid:
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" AutoGenerateColumns="False" StyleSetName="Office2010Blue" Width="1160px" Height="500px" ItemCssClass="borderClass" EnableAjax="False"> <GroupingSettings EnableColumnGrouping="True">GroupingSettings> <Columns>
<ig:BoundDataField DataFieldName="MA_ID" Hidden="True" Key="MA_ID" Width="60px"> <Header Text="MA_ID"> Header> ig:BoundDataField>
// tons of column definitions...
Columns> <Behaviors> <ig:EditingCore AutoCRUD="False" BatchUpdating="True"> <Behaviors>
<ig:CellEditing><CellEditingClientEvents EnteringEditMode="WebDataGrid1_CellEditing_EnteringEditMode" ExitedEditMode="WebDataGrid1_CellEditing_ExitedEditMode" />
<ColumnSettings> <ig:EditingColumnSetting ColumnKey="MA_ID" ReadOnly="true" /> <ig:EditingColumnSetting ColumnKey="KeyDescription" ReadOnly="true" /> ColumnSettings> ig:CellEditing>
Behaviors>
ig:EditingCore>
<ig:Sorting> ig:Sorting>
<ig:ColumnMoving> ig:ColumnMoving>
<ig:ColumnResizing> ig:ColumnResizing>
ig:WebHierarchicalDataGrid>
I'm only using the WebHierarchicalDataGrid instead of a WebDataGrid because of it's Excel style columnGrouping feature.
thanks a lot for your help
Kevin
Thank you for posting in Infragistics forum.
It sounds like you have followed the correct steps to use Manual CRUD operations and Batch Updating feature with WHDG:
1) Enable Batch Updating
2) Set Auto CRUD to false
3) Handle the server side RowUpdating event ( or the other evens related to CRUD operations)
Could you please clarify what is the EnableAJAX property of the WHDG set to and if you data bind the grid in the RowUpdating event. I suggest setting the EnableAJAX property to false and call the DataBind() method in the RowUpdating event. Please let me know if this helps.
You can find more useful info on implementing Manual CRUD operations and Batch Updating on the following links:
http://es.infragistics.com/community/blogs/radoslav_minchev/archive/2010/12/18/manual-crud-webhierarchicaldatagrid.aspx
http://es.infragistics.com/samples/aspnet/data-grid/batch-updating-events
http://es.infragistics.com/samples/aspnet/hierarchical-data-grid/batch-updating
I will ask you to provide a feedback if the suggested helped you resolve your issue. If not please provide your code with your WHDG configuration and the code you execute in the RowUpdating event. I will be happy to assist you further.