Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hi,

I am getting the following error while clicking on the update button on my page.
Please help me in this regard.

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.HttpRequest.FillInFormCollection() +9036234
System.Web.HttpRequest.get_Form() +104
System.Web.HttpRequest.get_HasForm() +9036751
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +97
System.Web.UI.Page.DeterminePostBackMode() +69
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +135





thanks in advance
Posted
Updated 4-Nov-12 22:03pm
v2
Comments
Storxstar 5-Nov-12 4:06am    
Could you supply us with the line of code that this executes on?
Sourin Chakraborty 5-Nov-12 4:17am    
protected void UpdateData(object sender, EventArgs e)
{
try
{
DataTable dt = new DataTable("VotersStat");

dt.Columns.Add("acid", typeof(int));
dt.Columns.Add("psid", typeof(int));
dt.Columns.Add("male", typeof(string));
dt.Columns.Add("female", typeof(string));
dt.Columns.Add("other", typeof(string));
dt.Columns.Add("epic", typeof(string));

foreach (GridViewRow grd in this.grdVotersTurnout.Rows)
{
int ACID = int.Parse((grd.FindControl("LitACID") as Literal).Text);
int PSID = AuxiliaryFunctions.GetPSIDByAuxiliaryValue((grd.FindControl("LitPSID") as Literal).Text);

int male, female, other, epic;

bool status = int.TryParse((grd.FindControl("TxtVMALE") as TextBox).Text, out male);

if (!status)
{
grd.Focus();
(grd.FindControl("TxtVMALE") as TextBox).Focus();
throw new Exception("Please check the value in male column for AC " + ACID + " and PS " + AuxiliaryFunctions.PSIDWithAuxiliaryValue(PSID));
}

status = int.TryParse((grd.FindControl("TxtVFEMALE") as TextBox).Text, out female);

if (!status)
{
grd.Focus();
(grd.FindControl("TxtVFEMALE") as TextBox).Focus();
throw new Exception("Please check the value in female column for AC - " + ACID + " and PS " + AuxiliaryFunctions.PSIDWithAuxiliaryValue(PSID));
}

status = int.TryParse((grd.FindControl("TxtVOTHER") as TextBox).Text, out other);

if (!status)
{
grd.Focus();
(grd.FindControl("TxtVOTHER") as TextBox).Focus();
throw new Exception("Please check the value in other column for AC - " + ACID + " and PS " + AuxiliaryFunctions.PSIDWithAuxiliaryValue(PSID));
}

status = int.TryParse((grd.FindControl("TxtEpic") as TextBox).Text, out epic);

if (!status)
{
grd.Focus();
(grd.FindControl("TxtEpic") as TextBox).Focus();
throw new Exception("Please check the value in epic column for AC - " + ACID + " and PS " + AuxiliaryFunctions.PSIDWithAuxiliaryValue(PSID));
}

string smale = string.Empty, sfemale = string.Empty, sother = string.Empty;

if (male > 0 || female > 0 || other > 0)
{
smale = male.ToString();
sfemale = female.ToString();
sother = other.ToString();
}

DataRow dr = dt.NewRow();

dr["acid"] = ACID;
dr["psid"] = PSID;
dr["male"] = smale;
dr["female"] = sfemale;
dr["other"] = sother;
dr["epic"] = epic.ToString();

dt.Rows.Add(dr);
}

dt.AcceptChanges();

foreach (DataRow dr in dt.Rows)
dr.SetModified();

try
{
FinalVotersTurnout fvt = new FinalVotersTurnout();
int flag = fvt.UpdateFinalVotersTurnout(dt);

if (flag == 1)
{
this.lblMsg.Visible = true;
this.lblMsg.Text = "Voters Turnout has been updated successfully.";

this.isEditMode = false;

this.ViewState["EditMode"] = fals
Kschuler 5-Nov-12 12:18pm    
This is a mess for anyone to try to read in the comments. Please click the Improve Question link and update your original question to include this code in a nice formatted code block.

1 solution

Here is a link that should help you sort out your problem

The cause of the problem is:
SQL
The Microsoft security update that security bulletin MS11-100 addresses changes the default maximum number of form keys, files, and JSON members that ASP.NET will accept in a request to 1,000. This change was made to address the Denial of Service vulnerability that the Microsoft security bulletin MS11-100 documents.


http://support.microsoft.com/kb/2661403[^]

There is a fix in the link. Hope this helps

Thanks Storxstar
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900