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

iphone - How do I make a UIPickerView in a UIActionSheet -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -