Help??!! Error when working in Ch. 13
Hi, I'm in Ch. 13 also. I am on the exercise where you create a page called NewPhotoAlbum.aspx. I have set-up and double checked my linq dbml diagram.
I believe I have done the exercise correctly, but I get this error:
Compiler Error Message: CS1061: 'PhotoAlbum' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'PhotoAlbum' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 23: // Label1.Text = long_text;
Line 24: PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Result;
Line 25: Response.Redirect(string.Format("ManagePhotoAlbum. aspx?PhotoAlbumId={0}", myPhotoAlbum.Id.ToString()));
Line 26: }
Line 27: }
This is when I first load the page. If I comment out line 25, the page loads fine and throws an error when I submit it:
Unable to cast object of type 'PhotoAlbum' to type 'PhotoAlbum'.
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.InvalidCastException: Unable to cast object of type 'PhotoAlbum' to type 'PhotoAlbum'.
Source Error:
Line 22: // string long_text = e.Result.ToString();
Line 23: // Label1.Text = long_text;
Line 24: PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Result;
Line 25: // Response.Redirect(string.Format("ManagePhotoAlbum. aspx?PhotoAlbumId={0}", myPhotoAlbum.Id.ToString()));
|