Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2011, 01:38 AM
Authorized User
 
Join Date: Aug 2011
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Thumbs down Collection is read-only Error

Hi,
I am getting this error -:
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.NotSupportedException: Collection is read-only.

Source Code
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Report")
{

string question = e.CommandArgument.ToString();
Request.QueryString["roll"] = question; //here I am getting error
Response.Redirect("~/Report/CrystalReport.aspx");
}
}

Please do lemme know the solution for it...

Thanks
Emma
 
Old August 15th, 2011, 05:12 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Emma,

As the error message suggestd, the QueryString collection is read-only. You can read values from it, but not assign to it. Instead, you need to pass your values through the query string part of the address. For example:

Code:
Response.Redirect("~/Report/CrystalReport.aspx?roll=" + e.CommandArgument.ToString());
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception error "Collection was modified; enumeration operation may not execute" caof2005 BOOK: Professional ASP.NET MVC 2 1 April 6th, 2011 07:26 PM
Getting Error: Item cannot be found in the collection corresponding to the requested dalezjc Classic ASP Basics 11 January 16th, 2009 10:38 AM
Read First !! An Important Error Stephen Lam Wrox Book Feedback 1 May 6th, 2005 05:05 PM
Read only Database error larry101 Classic ASP Databases 4 September 11th, 2004 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.