This is a migrated thread and some comments may be shown as answers.

SPContext, SQL and RadGrid Filtering

1 Answer 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carolee
Top achievements
Rank 1
Carolee asked on 11 Sep 2012, 11:20 AM
Would anyone be willing to show me how to write the code to use SPContext in order to get the UserName (without Domain) of the currently logged in SharePoint user, and then to Query a SQL Server external content source for items in a field called "Assignee" where the logged in name is contained in the Assignee? 

Further, could you then tell me how to load that query into a RadGrid by default.... But to be able to clear the filter (or apply a new one) when desired?

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 14 Sep 2012, 09:40 AM
Hi,

 The SPContext.Current.Web.CurrentUser.LoginName return the user and the domain but you can easily split the string and get only the user name.
You can query an external SQL server using BCS in SP 2010 as shown in this article.

You can use the NeedDataSource event of the grid to bind to any data by default. There you can also change the datasource when the filter is cleared.

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Carolee
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or