This is a migrated thread and some comments may be shown as answers.

Operation is not valid due to the current state of the object.

1 Answer 192 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Cecil asked on 23 Jan 2012, 01:13 AM
I started with a simple grid on a page as follows:
<telerik:RadGrid ID="rgSelectCourses" runat="server" AllowSorting="True"
     Width="860px" Height="500px" PageSize="20" CellSpacing="0"
     DataSourceID="sdsCourses" AllowMultiRowSelection="True"
     GridLines="None" AutoGenerateColumns="False">
         <Scrolling AllowScroll="True" UseStaticHeaders="True" />
         <Selecting AllowRowSelect="true" />
     <MasterTableView DataKeyNames="Course_Code" DataSourceID="sdsCourses">
         <CommandItemSettings ExportToPdfText="Export to PDF" />
         <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
         <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
             <telerik:GridClientSelectColumn Reorderable="False" UniqueName="ClientSelectColumn" HeaderText="Select">
             <HeaderStyle Width="50px"></HeaderStyle>
         <telerik:GridBoundColumn UniqueName="Course_Code" SortExpression="Course_Code" HeaderText="Code"
             <HeaderStyle Width="130px"></HeaderStyle>
             <ItemStyle HorizontalAlign="Left" />
          <telerik:GridBoundColumn UniqueName="Course_Title" SortExpression="Course_Title" HeaderText="Title"
             <HeaderStyle Width="200px"></HeaderStyle>
             <ItemStyle HorizontalAlign="Left" />
         <telerik:GridTemplateColumn FilterControlAltText="Filter column1 column" HeaderText="Expiration Date" UniqueName="column1">
             <HeaderStyle HorizontalAlign="Center" />
             <ItemStyle Width="120px" HorizontalAlign="Center" />
                 <telerik:RadComboBox ID="rgTime" runat="server" Width="35px">
                         <telerik:RadComboBoxItem runat="server" Text="1" Value="1" />
                         <telerik:RadComboBoxItem runat="server" Text="2" Value="2" />
                         <telerik:RadComboBoxItem runat="server" Text="3" Value="3" />
                         <telerik:RadComboBoxItem runat="server" Text="4" Value="4" />
                         <telerik:RadComboBoxItem runat="server" Text="5" Value="5" />
                         <telerik:RadComboBoxItem runat="server" Text="6" Value="6" />
                         <telerik:RadComboBoxItem runat="server" Text="7" Value="7" />
                         <telerik:RadComboBoxItem runat="server" Text="8" Value="8" />
                         <telerik:RadComboBoxItem runat="server" Text="9" Value="9" />
                         <telerik:RadComboBoxItem runat="server" Text="10" Value="10" />
                         <telerik:RadComboBoxItem runat="server" Text="11" Value="11" />
                         <telerik:RadComboBoxItem runat="server" Text="12" Value="12" />
                 <telerik:RadComboBox ID="rgInterval" runat="server" Width="60px">
                         <telerik:RadComboBoxItem runat="server" Text="Years" Value="Years" />
                         <telerik:RadComboBoxItem runat="server" Text="Months" Value="Months" />
         <telerik:GridTemplateColumn FilterControlAltText="Filter column2 column"
             HeaderText="Comments..." UniqueName="column2">
             <HeaderStyle Width="300px" HorizontalAlign="Left" />
             <ItemStyle HorizontalAlign="Left" />
                 <telerik:RadTextBox ID="rtbComment" runat="server" TextMode="Multiline"
                     Height="63px" Width="290px" />
             <EditColumn FilterControlAltText="Filter EditCommandColumn column">
     <FilterMenu EnableImageSprites="False">
     <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
 <asp:SqlDataSource ID="sdsCourses" runat="server"
     ConnectionString="<%$ ConnectionStrings:SafetyPlusWebConnectionString %>"
     SelectCommand="SELECT [Course_Code], [Course_Title], [Renewal_Interval], [Time_Frame] FROM [Courses] WHERE [Active] = 1 ORDER BY [Course_Code]">

Everything worked perfectly.  I could select and edit items at will.

But, I needed to get the selected items into a database.  I chose to put a radbutton below the grid for the user to click when they had made all their changes.

<telerik:RadButton ID="RadButton1" runat="server" Text="Next" OnClick="RadButton1_Click" ></telerik:RadButton>

When the button is clicked, I get the following:
Operation is not valid due to the current state of the object.
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.InvalidOperationException: Operation is not valid due to the current state of the object.
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:
[InvalidOperationException: Operation is not valid due to the current state of the object.]
   System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +83
   System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +111
   System.Web.HttpRequest.FillInFormCollection() +307
[HttpException (0x80004005): The URL-encoded form data is not valid.]
   System.Web.HttpRequest.FillInFormCollection() +404
   System.Web.HttpRequest.get_Form() +85
   System.Web.HttpRequest.get_Item(String key) +94
   Telerik.Web.UI.RadCompression.IsAjaxRequest() +59
   Telerik.Web.UI.RadCompression.Compress(HttpApplication application) +770
   Telerik.Web.UI.RadCompression.PreRequestHandlerExecute(Object sender, EventArgs e) +76
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +221
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +120
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Any thoughts on how to correct this?


1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 24 Jan 2012, 03:43 PM

I'm not sure if this is applicable to your situation, since I'm not privy to the details of your database update, but this recent post (1/18/2012) is worth reviewing, if you've not yet done so:

MS Update MS11-100 breaks sites with more than 1000 parameters at

Hope this helps!
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question