views:

333

answers:

1

So I am using the SL4 Business Template and the SQL Membership API. I created a user and I created a custom table that ties to that user.

So I want to have a datagrid that show the item for the CURRENT (WebContext.Current.User) user.

  1. Why is the GUID for the user in WebContext.Current.User??? I need that to join to the 'Items' table.

  2. How can I use the XAML DomainDatasource... from what I see you can only use it if you can bind to something else on the XAML.. for example if I have a calendar control on the page I can bind the domaindatasource to the calendar.... But I want to query giving the 'UserID (GUID)'... so do I need to put a hidden field on the XAML with that value to have access to it? (like the hidden fileds in asp.net)

or am I going about it all the wrong way... its a really simple conceopt.. I have users.. I have items.. there is a relationship.. and I want a datagrid filled with items for a particular user.

+1  A: 

There are two ways to approach this. First, you could just write a query GetDataForCurrentUser() and pull the current user on the server. This tends to be the more secure option since a user can only get their own data. The second option is to pass the user guid as a parameter. In this post, I show a couple ways to do just that.

http://jeffhandley.com/archive/2010/03/18/custom-filter-parameter.aspx

Kyle McClellan
im confused at first glance... you are talking about getting the UserID GUID using forms authentication + the built in SQL membership tables right? ill look at your code more clsely tomorrow.
punkouter
I look into it more.. I still don't get it.. I used the code from your sample to pass the User.Name...But what I want is the PrimaryKey which is the User GUID... how do I get that value???I need that key to then match up the user with 'Items' This seems like such a commmon thing to do with the SQL Membership tables I dunno why it seems hard to me.
punkouter
well worst case I can just join with the 'Name' string atleast...
punkouter
Sorry. I assumed you were familiar with the RIA authentication support. If that isn't the case, you can start with a tutorial (http://msdn.microsoft.com/en-us/library/ee707361(v=VS.91).aspx) or some samples (http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2661).
Kyle McClellan
Also, User.Name should be treated as the unique user identifier (primary key). It sounds like it would be best if it had the User GUID in it.
Kyle McClellan
so... I need to figure out how to get the GUID property in the User object... The seems to be the missing piece of the puzzle im not understanding?
punkouter
did you mean 'should' or 'should not'
punkouter
It 'should' be a unique identifier. It's a side-effect of implementing the IPrincipal interface (typically the name is associated with your login name). If your identifier is a guid, use that. If you want to store the user's name somewhere, add another property and put it in your tables or add it as a profile property.
Kyle McClellan