Hi, here is the behavior I'm attempting to produce:
Everything works fine until I perform a postback. At that point I get this error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +14281985 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +305 System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +859 Infragistics.Web.UI.Framework.Data.DataBot.ChangeType(Object value, Type toType, CultureInfo culture) +449 Infragistics.Web.UI.GridControls.EditingCore.OnAction(String actionType, Object id, Object value, Object tag) +11228 Infragistics.Web.UI.GridControls.GridBot.LoadAdditionalClientState(Object state) +2329 Infragistics.Web.UI.Framework.RunBot.HandleRaisePostDataChangedEvent() +144 Infragistics.Web.UI.GridControls.GridBot.HandleRaisePostDataChangedEvent() +79 System.Web.UI.Page.RaiseChangedEvents() +333 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3572
To create the row, I'm using using this code:
<input language="javascript" id="AddButton" onclick="return AddButton_onclick()" type="button" value="Add" name="AddButton" runat="server" />
<script type="text/javascript" language="javascript" id="clientEventHandlersJS"> <!--
function AddButton_onclick() {var grid = $find('<%= me.InfoGrid.ClientID %>'); var rows = grid.get_rows(); var rowsLength = rows.get_length(); // Create array of cell values for all values that cannot be null. var row = new Array("", "", "", "", "", ""); // Add row. rows.add(row); var lastRow = rows.get_row(rowsLength); var cell = lastRow.get_cell(0); grid.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().enterEditMode(cell); }
//--> </script>
Here is how the WebDataGrid is defined:
Hello,
You are trying to pass an empty string for the ID column which causes the exception.
In other words
var row = new Array("", "", "", "", "", "");
the fifth item of the array should be an integer.
For example:
var row = new Array("", "", "", "", 42, "");
Let me know if I may be of further assistance.
Hi Denis, thanks for the suggestion. That seems a bit odd to me though because the ID isn't generated until the record is entered into the database which happens after postback. From my understand that javascript function is simply creating the row on the client side before postback.
When I use the grid's native add row functionality and the row is added to the grid the ID column is 0 as I expect it to be because the entry doesn't have an ID until it's sent to the db.
I've actually moved on from trying to use the javascript approach and am just sticking with the grid's built in add row functionality so if you'd like to consider this request complete that is fine with me.