Server Error in '/' Application.

Input string was not in a correct format.

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.FormatException: Input string was not in a correct format.

Source Error:


Line 42:                      Session["creator"] = null;
Line 43:                   Session["g2"] = null;
Line 44:                     var p = d.Groups.SingleOrDefault(x => x.GroupId == Convert.ToInt32(Session["g3"]));
Line 45:                  if (p != null)  {
Line 46:                      Session["gg2"] = p.Group2Id;

Source File: c:\inetpub\vhosts\offkade.org\httpdocs\product.aspx.cs    Line: 44

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12526913
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +120
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +46
   System.Convert.ToInt32(Object value) +30
   lambda_method(Closure ) +72

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
   System.Delegate.DynamicInvokeImpl(Object[] args) +117
   System.Data.Linq.CommonDataServices.GetKeyFromPredicate(MetaType type, Dictionary`2 keys, Expression mex, Expression vex) +473
   System.Data.Linq.CommonDataServices.GetKeysFromPredicate(MetaType type, Dictionary`2 keys, Expression expr) +257
   System.Data.Linq.CommonDataServices.GetKeyValues(MetaType type, LambdaExpression predicate) +93
   System.Data.Linq.CommonDataServices.GetCachedObject(Expression query) +569
   System.Data.Linq.SqlClient.SqlProvider.GetCachedResult(Expression query) +44
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +91
   System.Data.Linq.Table`1.System.Linq.IQueryProvider.Execute(Expression expression) +58
   System.Linq.Queryable.SingleOrDefault(IQueryable`1 source, Expression`1 predicate) +249
   product.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\offkade.org\httpdocs\product.aspx.cs:44
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0