If the user selects a different item in the LocationTypeId dropdown and immediately clicks the test button, the call to alert() correctly shows the user's new selection, then the form is submitted. Immediately after that, on the server-side, if I examine the rows of the grid at the very first line of the Page_Load method, the value of that dropdown's column is still the old value, as if the user's new selection was never made. Why is that? Am I doing something wrong?
<iggrid:WebDataGrid id="grdISOGeneralLiabilityModel" runat="server" AutoGenerateColumns="false"EnableDataViewState="true"><EditorProviders><iggrid:DropDownProvider ID="DropDownProviderForStateId"><EditorControl ID="EditorControl4" runat="server" DisplayMode="DropDownList"</EditorControl></iggrid:DropDownProvider><iggrid:DropDownProvider ID="DropDownProviderForLocationTypeId"><EditorControl ID="EditorControl5" runat="server" DisplayMode="DropDownList"></EditorControl></iggrid:DropDownProvider></EditorProviders><Columns><iggrid:BoundDataField DataFieldName="RatingGLId" key="RatingGLId" hidden="true"></iggrid:BoundDataField><iggrid:BoundDataField DataFieldName="StateId" key="StateId"></iggrid:BoundDataField><iggrid:BoundDataField DataFieldName="LocationTypeId" key="LocationTypeId"></iggrid:BoundDataField></Columns><Behaviors><iggrid:Selection CellClickAction="Row" RowSelectType="Single"></iggrid:Selection><iggrid:EditingCore AutoCRUD="false"><Behaviors><iggrid:CellEditing><ColumnSettings><iggrid:EditingColumnSetting ColumnKey="StateId" EditorID="DropDownProviderForStateId" /><iggrid:EditingColumnSetting ColumnKey="LocationTypeId" EditorID="DropDownProviderForLocationTypeId" /></ColumnSettings><EditModeActions EnableOnActive="True" MouseClick="Single" /></iggrid:CellEditing></Behaviors></iggrid:EditingCore></Behaviors></iggrid:WebDataGrid>
<input type="button" id="myTestButton" onclick="myTestButtonHandler()" value="Test" />
function myTestButtonHandler(sender, eventArgs) {var grid = $find('<% = grdISOGeneralLiabilityModel.ClientID %>');var selectedLocationType = grid.get_behaviors().get_selection().get_selectedRows(0).getItem(0).get_cellByColumnKey("LocationTypeId").get_value() + "=" +grid.get_behaviors().get_selection().get_selectedRows(0).getItem(0).get_cellByColumnKey("LocationTypeId").get_text();alert(selectedLocationType);jQuery("[id$='aspnetForm']").submit();}
Hello Michael,
Thank you for posting in our forums.
To get the updated value of the drop down I would recommend instead of page load use rowUpdated event.On page load event you will not be able to get updated value of the dropdown.Please follow the code snippet :
In the markup:
<iggrid:WebDataGrid id="grdISOGeneralLiabilityModel" runat="server" AutoGenerateColumns="false"EnableDataViewState="true" OnRowUpdated ="grid_RowUpdated">
Code behind
protected void grid_RowUpdated(object sender, RowUpdatedEventArgs e) { var item = grdISOGeneralLiabilityModel.Rows[0].Items[5].Value;// item5 is dropdown column System.Diagnostics.Debug.WriteLine(item); }
Please note in the following markup you are missing closing tag of the EditorControl and I think this is typing error.
<EditorControl ID="EditorControl4" runat="server" DisplayMode="DropDownList"</EditorControl>
Please let me know if I may be further assistance.
When AutoCRUD is set to 'false', handle RowUpdating, RowDeleting and RowAdding events to perform manual updates. In your case you can use RowUpdating event to get updated dropdown value.
<iggrid:WebDataGrid id="grdISOGeneralLiabilityModel" runat="server" AutoGenerateColumns="false" EnableDataViewState="true" OnRowUpdating ="grid_RowUpdating" >
protected void grid_RowUpdating(object sender, RowUpdatingEventArgs e)
{
var dropDown = e.Values["DropDownColumn"].ToString();
}
So is it true that if AutoCRUD=false, the only opportunity I have to detect what data was changed by the user is in the RowUpdating event?
Hi Divya,
I know you're trying to give me as much information as possible and I appreciate that. However, the extra info you provided detracted from the precision of the answer I need. Therefore, could you please answer the following question with only one word (either Yes or No). Please note the importance of the word "only" in my question.
Is it true that if AutoCRUD=false, the only opportunity I have to detect what data was changed by the user is in the RowUpdating event?
Thanks,
-Lee
is it true that if AutoCRUD=false, the only opportunity I have to detect what data was changed by the user is in the RowUpdating event?
Hello Lee,
The answer is 'YES'.
Please let me know if i may be further assistance.
After experimenting further, I think this needs clarification. Yes, the RowUpdating event appears to be the only place that Infragistics gives you both the old and new values of the grid data. However, as long as the RowUpdating event has finished executing, the grid itself will have the new values in its Rows property. I tested this by setting a breakpoint in the grid's Load, RowUpdating, and Unload events. During a postback, Load fires first, then RowUpdating, then Unload. During the Load and RowUpdating events, the grid's Rows property contains the data as it was *BEFORE* the user edited it. However, by the time the Unload event executes, the Rows property contains the data as it was *AFTER* the user edited it.
I hope this helps someone.