Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Specified cast is not valid
Message
De
01/06/2010 11:44:59
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Specified cast is not valid
Divers
Thread ID:
01466885
Message ID:
01466885
Vues:
104
I'm trying to add a Beneficiary to an Insurance Policy using an mmGridView. I've done this type of thing before without this error, so I'm pretty sure it's something silly I'm missing.

The line of code that is crashing is this:
Guid newPK = (Guid)dsBeneficiary.Tables[0].Rows[dsBeneficiary.Tables[0].Rows.Count - 1]["BeneficiaryPK"];
just prior to this line I do a:
this.oBeneficiary.NewRow(dsBeneficiary, this.oBeneficiary.TableName);
My Beneficiary .cs sets a default BeneficiaryPK using:
entity.BeneficiaryPK = Guid.NewGuid();
The Watch window shows {} as the value for dsBeneficiary.Tables[0].Rows[dsBeneficiary.Tables[0].Rows.Count - 1]["BeneficiaryPK"].

The full error is this:
System.InvalidCastException was unhandled by user code
  Message="Specified cast is not valid."
  Source="SamaanSystems.IAS.Web"
  StackTrace:
       at SamaanSystems.IAS.Web.PolicyEdit.btnAddBeneficiary_Click(Object sender, EventArgs e) in C:\Development\Mere Mortals .NET Framework 2008\SamaanSystems\IAS.Web\PolicyEdit.aspx.cs:line 592
       at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
       at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:
Any ideas what I have done wrong?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform