This issue has me totally lost.
I have a formview with several radcontrols and a UserControl.
The user control has a RadGrid and an ObjectDataSource.
When I call the UpdateItem method on the formview with the following code:
I get the following exception:
InvalidOperationException: Collection was modified; enumeration operation may not execute
Here's the stack trace:
-------------
The stack trace doesn't say much and didn't help me track the problem, but I ended up figuring out that what was causing the problem is a GridDateTimeColumn defined inside the radgrid (there's only one datetime column) that's inside my user control as such:
When I remove this column, the call to the formview's UpdateItem method works well. When I put it back, I get the error again. I tried playing w/ the properties, binding to another datetime column, recreating the whole file from scratch, removing everything in the code behind file of the user control, and nothing works. The weird thing is, I have datetime columns in other usercontrols built the same way, and everything works fine there.
Here's the usercontrol definition:
Any ideas? :(
I have a formview with several radcontrols and a UserControl.
The user control has a RadGrid and an ObjectDataSource.
When I call the UpdateItem method on the formview with the following code:
protected
void
BtnSave_Click(
object
sender, EventArgs e)
{if
(Page.IsValid)
{
this
.MyFormView.UpdateItem(
true
);
}
}I get the following exception:
InvalidOperationException: Collection was modified; enumeration operation may not execute
Here's the stack trace:
at System.Web.UI.ControlCollection.ControlCollectionEnumerator.MoveNext()
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
at System.Web.UI.WebControls.DataBoundControlHelper.ExtractValuesFromBindableControls(IOrderedDictionary dictionary, Control container)
-------------
The stack trace doesn't say much and didn't help me track the problem, but I ended up figuring out that what was causing the problem is a GridDateTimeColumn defined inside the radgrid (there's only one datetime column) that's inside my user control as such:
<
telerik:GridDateTimeColumn
DataField
=
"DeadlineDate"
UniqueName
=
"DeadlineDate"
DataFormatString
=
"{0:dd MMM yyyy}"
HeaderText
=
"Deadline"
/>
When I remove this column, the call to the formview's UpdateItem method works well. When I put it back, I get the error again. I tried playing w/ the properties, binding to another datetime column, recreating the whole file from scratch, removing everything in the code behind file of the user control, and nothing works. The weird thing is, I have datetime columns in other usercontrols built the same way, and everything works fine there.
Here's the usercontrol definition:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GridViewTest.ascx.cs"
Inherits="TestSolution.WebUI.UserControls.GridViewTest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
telerik:RadGrid
ID
=
"TestRadGrid"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AutoGenerateColumns
=
"false"
AllowPaging
=
"True"
AllowSorting
=
"True"
CellSpacing
=
"0"
DataSourceID
=
"TestDataSource"
GridLines
=
"None"
Skin
=
"Office2007"
>
<
MasterTableView
EditMode
=
"InPlace"
DataKeyNames
=
"PeriodID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"PeriodID"
UniqueName
=
"PeriodID"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"SpecificityID"
UniqueName
=
"SpecificityID"
/>
<
telerik:GridDateTimeColumn
DataField
=
"DeadlineDate"
UniqueName
=
"DeadlineDate"
DataFormatString
=
"{0:dd MMM yyyy}"
HeaderText
=
"Deadline "
/>
<
telerik:GridBoundColumn
DataField
=
"DeadlineDate"
UniqueName
=
"DeadlineDate"
HeaderText
=
"Deadline"
/>
<
telerik:GridNumericColumn
DataField
=
"OutstandingAmountBeforeDeadline"
UniqueName
=
"OutstandingAmountBeforeDeadline"
NumericType
=
"Number"
HeaderText
=
"O/S Before Repayment"
/>
<
telerik:GridNumericColumn
DataField
=
"InterestAmount"
UniqueName
=
"InterestAmount"
NumericType
=
"Number"
HeaderText
=
"Interest"
/>
<
telerik:GridCheckBoxColumn
DataField
=
"ToDelete"
UniqueName
=
"ToDelete"
HeaderText
=
"Delete"
/>
<
telerik:GridEditCommandColumn
ButtonType
=
"PushButton"
InsertText
=
"Insert"
EditText
=
"Edit"
CancelText
=
"Cancel"
UniqueName
=
"EditCommandColumn"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:ObjectDataSource
ID
=
"TestDataSource"
runat
=
"server"
TypeName
=
"TestSolution.WebUI.ObjectDataSource.TestDataSource"
SelectMethod
=
"GetTestTableByCriterias"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"TestType"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"SpecificityID"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:ObjectDataSource
>
Any ideas? :(