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
I'm getting the same error on a page with 2 grids. Both are bould to a non-persistent DataSource (SQL DataSet) on button click.
Grid_1 has DataViewState enabled. It is rebound on each button click.
Grid_2 has DataViewState disabled and filtering enabled. The DataSource is saved to a session variable and rebound during Page_Load. If the user clicks the button, and new DataSet is retrieved, set as the DataSource and then saved to the session variable for next postback.
I know I should not call ClearDataSource() during Page_Load as that will clear and selected cells on postback. Should I be calling ClearDataSource() during button click before binding the new DataSet?
// Convergence Waves
DataSet waves = Common.GetDataSetSQL("EXEC [dbo].[GetAppWaves] 'LIST', '" + sSite + "'");
WebDataGridConvergenceWaves.DataSource = waves;
WebDataGridConvergenceWaves.DataBind();
// Vertical/Regional/DPTs
DataSet apps = Common.GetDataSetSQL("EXEC [dbo].[GetDeployableApplications] '" + WebDropDownRegion.SelectedItem.Value + "', '" + Session[HiddenField_SiteOfComputer.Value].ToString() + "'");
WebDataGridApplications.DataSource = apps;
WebDataGridApplications.DataBind();
// Save DataSet to session variable for grid filtering
Common.SaveDataset(apps, HiddenField_WebDataGridApplicationsDataSet.Value);
Hello Pete (BSC),
Please let me know if you have any other questions or concerns about this issue and I'll be glad to help you.
Hi Pete (BSC),
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.
I need a little more time to research this issue. I will have another update for you sometime tomorrow.
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.
If you have any questions or concerns with this, please let me know and I'll be glad to help.