asp.net - Getting a UserId into a SQLDataSource -


I am still new to ASP.NET and I have a problem that I can not understand. I am using vb and .net subscriptions API

My question is, how do I get the current user's useride in DetailsView INSERT?

  & lt; InsertParameters & gt; & Lt; ASP: Parameter Name = "User Id" /> & Lt; / InsertParameters & gt;    

In your SqlDataSource's OnInserting event, Code> ProviderUserKey can get UserID from the membership table using the membership user class property. You can then programmatically assign this value to the UserID Insert parameter.

  Protected Zero SqlDataSource_Inserting (Object Sender, SqlDataSourceCommandEventArgs e) {Membership User currentUser = Membership.GetUser (); Guid id = (Guid) currentUser.ProviderUserKey; E.Command.Parameters ["UserID"]. Value = id; }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -