I tried retrieving the user's data based on the logged in UserId, but no progress. Any suggestions?\[code\]protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e){ // Get a reference to the currently logged on user MembershipUser currentUser = Membership.GetUser(); // Determine the currently logged on user's UserId value Guid currentUserId = (Guid)currentUser.ProviderUserKey; // Assign the currently logged on user's UserId to the @UserId parameter e.Command.Parameters["@UserId"].Value = http://stackoverflow.com/questions/14414892/currentUserId; }\[/code\]And this is the \[code\]SqlDataSource\[/code\]\[code\] <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:NaviConnectionString %>' SelectCommand="SELECT [UserId], [FirstName], [LastName] FROM [UserProfiles] WHERE ([UserId] = @UserId)"> <SelectParameters> <asparameter Name="UserId" Type="String"></asparameter> </SelectParameters> </asp:SqlDataSource>\[/code\]And this is the \[code\]GridView\[/code\]\[code\]<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKFFeyNames="UserId" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." DataKeyNames="UserId"> <Columns> <asp:BoundField DataField="UserId" HeaderText="UserId" SortExpression="UserId" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> </Columns></asp:GridView>\[/code\]There are no data records to display.
However, when I execute the code in query builder, it works.So I need to get the \[code\]UserId\[/code\] manually from the database.
Then go to the query builder then execute then paste the \[code\]userid\[/code\] in to the value of \[code\]UserID\[/code\].
Then it displays the correct data based on the \[code\]UserId\[/code\]:
I also tried changing it to this:\[code\] <SelectParameters> <asparameter Name="UserId" Type="Empty" DbType="Guid"></asparameter> </SelectParameters>\[/code\]