locked
PageRequestManagerServerErrorException: Specified cast is not valid. RRS feed

  • Question

  • User1288251396 posted

    Dynamic Data newbie problem:

    On my edit page, when I click Update, I get this error:

    Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Specified cast is not valid.

    My debugger says it's happening in this JavaScript function:

    Sys$WebForms$PageRequestManager$_endPostBack(error, executor, data)

    When the Edit page opens, one of my foreign key dropdowns doesn't have a selected value.

    Any clues?

    TIA

    Wednesday, January 27, 2010 5:56 PM

Answers

  • User-330204900 posted

    That would explain it [:)]

    but was not the PK. 
     Linq to SQL does need it to be a PK for the relationship to work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 28, 2010 6:39 PM

All replies

  • User-330204900 posted

    Hi WombatEd, if you open up the site.master and edit the line that has EnablePartialRendering="true"  and change it to false the real error will show up [:)]

    Thursday, January 28, 2010 3:19 AM
  • User1288251396 posted

    site.master and edit the line that has EnablePartialRendering="true"  and change it to false the real error will show up

    Thanks, sjnaughton.

    That gets me to an error page that tells me the same thing, and I have no idea what it is that is being cast as what.

    [InvalidCastException: Specified cast is not valid.]
       System.Data.Linq.SingleKeyManager`2.TryCreateKeyFromValues(Object[] values, V& v) +59
       System.Data.Linq.IdentityCache`2.Find(Object[] keyValues) +28
       System.Data.Linq.StandardIdentityManager.Find(MetaType type, Object[] keyValues) +23
       System.Data.Linq.CommonDataServices.GetCachedObject(MetaType type, Object[] keyValues) +48
       System.Data.Linq.ChangeProcessor.GetOtherItem(MetaAssociation assoc, Object instance) +142
       System.Data.Linq.ChangeProcessor.BuildEdgeMaps() +254
       System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) +59
       System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +331
       System.Data.Linq.DataContext.SubmitChanges() +19
       System.Web.UI.WebControls.LinqToSqlWrapper.SubmitChanges(DataContext dataContext) +9
       System.Web.UI.WebControls.LinqDataSourceView.UpdateDataObject(Object dataContext, Object table, Object oldDataObject, Object newDataObject) +109
       System.Web.UI.WebControls.LinqDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +525
       System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92
       System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +837
       System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +509
       System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +113
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    
     
    
    



    Thursday, January 28, 2010 11:09 AM
  • User-330204900 posted

    Hi WombatEd, are you using GUID UniqueIdentifiers in your DB? 

    Thursday, January 28, 2010 11:38 AM
  • User1288251396 posted

    are you using GUID UniqueIdentifiers in your DB? 

    No.

    I've stumbled upon a work-around, but I don't know why it works.  I was getting these errors whenever the table I was editing (Table A) had a FK pointing to a VARCHAR(8) field in a second table (Table B).  The VARCHAR(8) field in Table B was indexed unique, but was not the PK.  Luckily, I had a third table, which had a one-to-one relationship to Table B, with the third table's PK being the same VARCHAR.  So I changed all the FKs to point to the third table.

    (Please folk's, not TOO many flames about this structure; I inherited it.)

    Thanks, Steve, for all your efforts.  If this makes any sense at all to you, I'm all ears.


    Thursday, January 28, 2010 2:53 PM
  • User-330204900 posted

    That would explain it [:)]

    but was not the PK. 
     Linq to SQL does need it to be a PK for the relationship to work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 28, 2010 6:39 PM
  • User1709880908 posted

    I am having the same problem, namely, changing in Site.Master EnablePartialRendering="true" throws PageRequestManagerServerErrorException when navigating through the tables. 

    My DB is full with GUIDs. Is there a solution to this issue?

    Thanks in advance,

    Ivar

    Thursday, June 13, 2013 5:59 AM
  • User-330204900 posted

    Hi ivzp, are you using Linq to SQL or Entity Framework? and when you say

    when navigating through the tables
    do  you mean clicking on foreign key and child links?

    Thursday, June 13, 2013 8:41 AM
  • User1709880908 posted

    I was probably not very specific in my post. I am using Entity Framework, with .Net version 4, Visual Studio 2010.

    I have generated a DynamicaData (DD) Web Site project from a Database (SQL Server 2008) in which almost every table has a Guid as Primary Key. I have introduced just one CalendarExtender from AjaxControlToolKit (you can guess that I am a beginner in DD).

    In Global.asax file I have introduced (in RegisterRoutes routine):

    DefaultModel.RegisterContext(typeof(LaudeaEntities), new ContextConfiguration() { ScaffoldAllTables = true });

    In Site.Master I am using:

            <asp:ScriptManager 
                ID="ScriptManager1" 
                runat="server" 
                EnablePartialRendering="false"
                EnableScriptGlobalization="true"
                EnableScriptLocalization="true"
                />

    Everything works ok so far. If I change 

    EnablePartialRendering="true"

    then, while browsing through the records of all tables with more than 10 records, the hit of "Next page" at the bottom of the record list, to see the next 10 records set, I get the JS error:

    Sys.WebForms.PageRequestManagerServerErrorException: Specified cast is not valid

    Well, the error is written in Spanish "La cadena de entrada no tiene el formato correcto.". I think that is the correct English translation, but I could be wrong.

    Thursday, June 13, 2013 11:52 AM
  • User1709880908 posted

    Actually I succeded in getting the English description of the exception:

    Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format.

    Please, excuse me about the confusion.

    Ivar

    Thursday, June 13, 2013 12:04 PM