Hello,
I worked through the chapter 16, page 578 Try It Out. Everything worked fine.
However, I want to use SQLDataSource, not LinqDataSource. If I change to SqlDataSource, I cannot get myPhotoAlbum.UserName which set up as User.Identity.Name.
Would you please help me and let me know how to get “User.Identity.Name when use SqlDataSource?
Thanks a lot.
The NewPhotoAlbum.asps.
vb is as below:
Code:
Partial Class NewPhotoAlbum
Inherits BasePage
Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting
Dim myPhotoAlbum As PhotoAlbum = CType(e.NewObject, PhotoAlbum)
myPhotoAlbum.UserName = User.Identity.Name
End Sub
End Class
The error message is as below:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'NewObject' is not a member of 'System.Web.UI.WebControls.SqlDataSourceCommandEve ntArgs'.
Source Error:
Line 9:
Line 10: Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEven tArgs) Handles SqlDataSource1.Inserting
Line 11: Dim myPhotoAlbum As PhotoAlbum = CType(e.NewObject, PhotoAlbum)
Line 12: myPhotoAlbum.UserName = User.Identity.Name
Line 13:
Source File: C:\AttendanceDatebase\Site\NewPhotoAlbum.aspx.
vb Line: 11