I've attached a sample project, inside the zip file is an overview.txt file that explains what we are trying to do in more detail.
How to reproduce:
If you start running the application and immediately click the search button – you see a postback and the results in the textboxes are displayed in the status textbox below:
But if you start the application and click around with the navigation controls (or select different rows on the grid) and then click on the search button – you get the following exception that appears to be coming from the grid control:
The string parameter 'key' cannot be null or empty. Parameter name: key
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.ArgumentException: The string parameter 'key' cannot be null or empty. Parameter name: key 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:
[ArgumentException: The string parameter 'key' cannot be null or empty.
Parameter name: key]
System.Web.UI.StateBag.get_Item(String key) +8820932
Infragistics.Web.UI.Framework.Data.DataRecord.GetValue(String fieldName) +87
Infragistics.Web.UI.GridControls.ControlDataRecord.GetValue(ControlDataField field) +240
Infragistics.Web.UI.GridControls.ControlDataItemCollection.GetValue(Int32 index) +207
Infragistics.Web.UI.GridControls.ControlDataItemCollection.GetValue(ControlDataItem item) +71
Infragistics.Web.UI.GridControls.ControlDataItem.get_Value() +47
Infragistics.Web.UI.GridControls.GridRecordItem.GetTextNode() +154
Infragistics.Web.UI.GridControls.ControlDataItem.Infragistics.Web.UI.GridControls.IXPathDataNavigableObject.get_Xml() +156
Infragistics.Web.UI.GridControls.XPathDataNavigable.GetNextSibling() +43
Infragistics.Web.UI.GridControls.XPathDataNavigator.MoveToNext() +87
Infragistics.Web.UI.GridControls.XPathDataNavigator.OutputToStream(XPathDataNavigator xpdn, XmlTextWriter stream, HtmlTextWriter htmlWriter) +329
Infragistics.Web.UI.GridControls.XPathDataNavigator.OutputToStream(XPathDataNavigator xpdn, XmlTextWriter stream, HtmlTextWriter htmlWriter) +318
Infragistics.Web.UI.GridControls.XPathDataNavigator.get_OuterXml() +199
Infragistics.Web.UI.GridControls.GridRenderer.RenderContents(HtmlTextWriter writer) +1251
Dear Pete (BSC),
Thank you for contacting Infragistics!
We have received your support request concerning your "string parameter 'key' cannot be null or empty" error, and this case has been assigned to me. Infragistics is dedicated to helping you solve this issue. Our team and I have done an initial review of your case and
I am looking into your sample and will get back to you by Friday with more information or questions for you.
If you have any questions or concerns with this, please let me know and I'll be glad to help.
Hi Pete (BSC),
I'm updating you to let you know that I'm able to reproduce the issue. I've found, so far, that this exception is being triggered when trying to access a BoundDataField "Field 9" which does not have a key assigned to it. I need some more time to research why this is occurring. I will have another update for you by Wednesday.
I need a little more time to research this issue. I will have another update for you sometime tomorrow.
This issue is being caused by the call to WebDataGrid1.ClearDataSource() in your ClearDataGrid() method. ClearDataSource() needs to be called when assigning a new DataSource to the grid. Since you're setting it to Nothing, there's no need to call ClearDataSource and this is causing the grid to think it has more columns than it should.
For more information on ClearDataSource, please see the following documentation:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=Infragistics4.Web.v12.2~Infragistics.Web.UI.GridControls.WebDataGrid~ClearDataSource.html
If you have any further questions or concerns with this issue, please let me know and I'll be glad to help.
Please disregard my previous message. I read the lifecycle policy and see that 2011 V1 is no longer supported. Thanks!
I'm encountering the same exception (The string parameter 'key' cannot be null or empty. Parameter name: key) in 11.1.20111.2238 (latest service release). Because the exception is unhandled, it's getting caught in global.asax, and users are being directed to the custom error page. I'm now looking at having to either upgrade Infragistics and deal with all of the testing and issues that will come out of that, or else replace the grid controls. Please let me know if upgrading to a more recent volume is my only option in terms of upgrading Infragistics. Please correct me if I'm wrong, but I'm guessing that's the case since 2011 V1 is pretty outdated now and is probably unsupported. Thank you.
Thanks. I was planning on updating to 20121.2156_SR already. Glad to know this corrects the known issue. I have already ensured .ClearDataSource() was called before binding a "new" DataSet. That is what I thought was correct, but still noticed the exceptions in the ASP.NET log on the production server. I plan to upgrade to 12.2 in the next quarterly release of my application. Thanks again.
Hello dc06663,
Thank you for your replies.
ClearDataSource should be called in any case when the grid's datasource is being changed (though this can be done just prior to setting the new changed source). It is not required when rebinding the grid to its previous source because it will, as you have noted, clear selection, reset scrollbar positions etc.
There is a known issue however with clearing the datasource when DataViewState is enabled, which results in the stated exception, which has been resolved in the latest service releases for Volumes 12.1 and 12.2 of NetAdvantage for ASP.NET. I would therefore suggest upgrading your product version or installing the latest SR for 12.1 or 12.2 in order to avoid this exception.
Please do not hesitate to contact me if you have any questions.
Feedback?