Hello,
I am using version 14.1.20141.2150 of the WebDataGrid. On my grid I have both row editing and row adding. I have four asp.net validation controls attached to four of the editor controls. This validation is only on row adding (This is because the respective fields are read only on row editing.)
Editor Providers:
<EditorProviders>
<ig:TextEditorProvider ID="tepFirstName">
<EditorControl ClientIDMode="Predictable"/>
</ig:TextEditorProvider>
<ig:TextEditorProvider ID="tepLastName">
<ig:TextEditorProvider ID="tepEmail">
<ig:MaskEditorProvider ID="mepPhone">
<EditorControl ID="ecPhone" ClientIDMode="Predictable" BorderStyle="None" InputMask="(###) ###-#### Ext. 99999"></EditorControl>
</ig:MaskEditorProvider>
<ig:TextEditorProvider ID="tepPhone">
</EditorProviders>
Row Adding Column Settings:
<ig:RowAddingColumnSetting ColumnKey="FirstName" ReadOnly="False" EditorID="tepFirstName" ValidatorID="valFirstNameRequired"/>
<ig:RowAddingColumnSetting ColumnKey="LastName" ReadOnly="False" EditorID="tepLastName" ValidatorID="valLastNameRequired"/>
<ig:RowAddingColumnSetting ColumnKey="Position" ReadOnly="False" />
<ig:RowAddingColumnSetting ColumnKey="EmailAddress" ReadOnly="False" EditorID="tepEmail" ValidatorID="cvEmail"/>
<ig:RowAddingColumnSetting ColumnKey="Phone" ReadOnly="False" EditorID="mepPhone" ValidatorID="cvPhone" />
Asp Validators:
<asp:RequiredFieldValidator runat="server" ID="valFirstNameRequired" ControlToValidate="wdgContacts" ForeColor="" CssClass="igg_NavisphereValidationErrorMessage" />
<asp:RequiredFieldValidator runat="server" ID="valLastNameRequired" ControlToValidate="wdgContacts" ForeColor="" CssClass="igg_NavisphereValidationErrorMessage" />
<asp:CustomValidator runat="server" ID="cvEmail" ControlToValidate="wdgContacts" CssClass="igg_NavisphereValidationErrorMessage" ClientValidationFunction="wdgContacts_cvEmail" />
<asp:CustomValidator runat="server" ID="cvPhone" ControlToValidate="wdgContacts" CssClass="igg_NavisphereValidationErrorMessage" ClientValidationFunction="wdgContacts_cvPhone"/>
The validation on row adding works correctly on the clientside but as soon as I click the save button to execute the post back it returns an "Object reference not set to an instance of an object." error occurs. The NullReferenceException appears to occur on the "ColumnEditSettings" Infragistics file at line 207. (Full File Path: Source\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\EditableBehaviorBase\ColumnEditSetting.cs:207 )
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.Web.UI.GridControls.ColumnEditSetting.SaveClientProperties() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\EditableBehaviorBase\ColumnEditSetting.cs:207 Infragistics.Web.UI.GridControls.RowAddingColumnSetting.SaveClientProperties() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\Editing\RowAdding\RowAddingColumnSetting.cs:123 Infragistics.Web.UI.Framework.ObjectBase.Infragistics.Web.UI.IClientState.SaveClientProperties() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:654 Infragistics.Web.UI.Framework.ObjectBase.WriteClientCollections(StringBuilder builder, ArrayList collections) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:870 Infragistics.Web.UI.Framework.ObjectBase.WriteClientState(StringBuilder builder) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:814 Infragistics.Web.UI.Framework.ObjectBase.Infragistics.Web.UI.IClientState.WriteClientState(StringBuilder builder) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:669 Infragistics.Web.UI.Framework.ObjectBase.WriteClientObjects(StringBuilder builder, ArrayList objects) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:839 Infragistics.Web.UI.Framework.ObjectBase.WriteClientState(StringBuilder builder) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:806 Infragistics.Web.UI.Framework.ObjectBase.Infragistics.Web.UI.IClientState.WriteClientState(StringBuilder builder) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:669 Infragistics.Web.UI.Framework.ObjectBase.WriteClientObjects(StringBuilder builder, ArrayList objects) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:839 Infragistics.Web.UI.Framework.ObjectBase.WriteClientState(StringBuilder builder) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\ObjectBase.cs:806 Infragistics.Web.UI.Framework.RunBot.PopulateScriptDescriptor(ScriptBehaviorDescriptor descriptor) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\RunBot.cs:290 Infragistics.Web.UI.GridControls.GridBot.PopulateScriptDescriptor(ScriptBehaviorDescriptor descriptor) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\GridControls\WebDataGrid\GridBot.cs:68 Infragistics.Web.UI.Framework.Data.<GetScriptDescriptors>d__0.MoveNext() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\Data\FlatDataBoundControl.cs:1109 System.Web.UI.ScriptControlManager.RegisterScriptsForScriptDescriptors(IEnumerable`1 scriptDescriptors, Control control) +63 System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +140 Infragistics.Web.UI.Framework.RunBot.RegisterScriptDescriptors() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\RunBot.cs:421 Infragistics.Web.UI.GridControls.GridBot.RegisterScriptDescriptors() in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\GridControls\WebDataGrid\GridBot.cs:646 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.Render(HtmlTextWriter writer) in e:\work\3\559\src\RELEASE\ASP.NET\2014.1\Source\Infragistics.Web.UI\Framework\Data\FlatDataBoundControl.cs:647 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 ASP.tasks_carrier_maintaincarriercontacts_aspx.__RenderContent1(HtmlTextWriter __w, Control parameterContainer) in C:\Workspaces\eComm\Navisphere\DEV\BidManagement.WebUI\Tasks\Carrier\MaintainCarrierContacts.aspx:77 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +268 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +216 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +128 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +57 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1386
Notes:
I was not able to create a basic example replicating this issue. There appears to be something wrong with the validator logic to hook the grid editor back up with the validator on postback/page render.
Questions:
What appears to be the issue here? Am I missing some attributes on my editors or validators that is causing the null exception?
Things I have tried:
I have tried adding the validators to the CellEditting ColumnSettings fields as well, in case it was throwing an error because it could no longer find the linked validators. This did not work.
Has anyone else had this issue and know what is causing it?
Thanks,
Mason
I also want to mention that I have verified that the Row Adding process works correctly with no exception when I do not have the Validation controls associated with the editor providers. Specifically when I remove the "ValidationID" property from the Row Adding Column Settings elements.
Hello Mason O'Neil,
Thank you for posting on our forums.
May I ask if you can provide more details about how you are handling the adding and updating a records on the server? Do you have AutoCRUD enabled? Are the record updated on the server without issues?
Please provide more details about your server-side logic and I will be happy to investigate this issue further.
I have attached the asp.net pages associated with the grid. The grid is populated by the ucWebDataGridHelper control via the ObjectDataSource.
Thank you for the information you've provided.
From what I can see so far, everything appears to be setup correctly, although I am unable to see what is done in the ucWebDataGridHelper. Note, Validation is done on the server before the page render on each postback. To learn more about the ASP.NET page lifecycle, please review the ASP.NET Page Life Cycle article on MSDN linked below:http://msdn.microsoft.com/en-us/library/ms178472(v=vs.85).aspx
What stage in the PageLife cycle are you repopulating the WebDataGrid on Postback? Can you update me with the logic you are using to in your custom ucWebDataGridHelper?
I believe this may be a timing issue and knowing when the WebDataGrid is populated will help in this regard.
I am looking forward to your update.
Inside the WebDataGridHelper, we populate the grid on PageLoad if it is not a postback. On PostBack, we simply assign the datasource again.
I have attached the WebDataGridHelper. You will notice the bind in the PageLoad method which calls ODS.Select(). You will see the actual bind process on the ODS.Selected() method.
Hello Mason,
Thank you for the last update.
In order to isolate the cause of this issue, I will need to reproduce this exception in my environment to find what is returning null. From my initial review of your code, I see that you are resetting the WebDataGrid in the Row_Adding event. Note, resetting the datasource at this stage may contribute to this behavior. Is there a particular reason why you are doing this?
I will be sure to update this thread with more details regarding my investigation once I have more information. I will be looking forward to your update regarding the reason for resetting the datasource later in the Page Life Cycle.
Thanks for your continued support in this issue.
In the RowAdding event I bind the data to the grid so that in the subsequent row I can determine what the row index of it's new row is. You cannot find the row without binding the data first. Using this row index we place the validation error (if it exists) next to the row in question and edit the erroneous cells. This worked for RowUpdating but is left over code from when I was attempting to do the same for RowAdding server side validation.
When I remove this code I still get the same error. I have removed the code and attached a new version of the WebDataGridHelper without the lines of code that bound the datagrid in RowAdding.
Thanks,Mason
After reviewing your code, I am unable to isolate the cause of this issue. For this reason, I have created a sample in an attempt to demonstrate the recommended approach for performing client and server-side validation with the WebDataGrid on RowAdding. Please review the sample and mimic this implementation in your application to see if this resolves the issue. Note, validation is achieved with a RangeValidator control for client-side validation and custom logic in the RowAdding event for server-side validation. If this is not possible, please let me know and I will attempt to use the code you provided to reproduce the behavior in my environment with the use of a sample.
Hi Jose, I don't see the sample attached that you referenced. Would you mind posting the sample again?
Thanks
Hi,
Please note that the link for my sample is on the bottom of my last post.