View Single Post
  #5 (permalink)  
Old July 28th, 2018, 03:06 AM
trurangimplant trurangimplant is offline
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Full

Originally Posted by nkiuk View Post

below is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PlanetWroxModel;

public partial class NewPhotoAlbum : BasePage
    protected void Page_Load(object sender, EventArgs e)


    protected void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e)
        PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Entity;
        Response.Redirect(string.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}", myPhotoAlbum.Id.ToString()));
I get a "Invalid Cast Exception was unhandled by user code" error
{"Unable to cast object of type 'PlanetWroxModel.PhotoAlbum' to type 'PhotoAlbum'."}
PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Entity;
Could someone please explain why and how I can fix this issue.

Can you show me full of code
Reply With Quote