SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an SPGridview and I made a CAML Query to get the modifier of a document. When I bind it to the SPGridview with a SPBoundfield the value is displayed like this:


All I want is that this field should be like a Sharepoint Standard SPFieldUser. How would I achieve this?

share|improve this question
I believe this may be very closely related:… – Stuart Pegg Aug 17 '11 at 22:19
Circular reference? :) – Rob D'Oria Aug 17 '11 at 23:17
@Stuart: So "closely related" = the same? haha :) – Kit Menke Aug 18 '11 at 2:33
@Kit: Haha! Oops! Is the one I was thinking of. – Stuart Pegg Aug 18 '11 at 7:20
@Rob: I did actually click that a couple times, thinking "Huh?" before I realised... – Stuart Pegg Aug 18 '11 at 7:21
up vote 1 down vote accepted

Thanks for the comments. I didn't ry them but they seem very helpful.

I solved it with an Templatefield too but created a class and used a Linkbutton. Here's the code:

   public class TemplatedUserControl : ITemplate
    private string loginName;
    private string displayName;

    public TemplatedUserControl(string loginName, string displayName)
        this.loginName = loginName;
        this.displayName = displayName;

    public void InstantiateIn(Control container)
        LinkButton referUser = new LinkButton();
        referUser.DataBinding += new EventHandler(referUser_DataBinding);

    private void referUser_DataBinding(object sender, EventArgs e)
        LinkButton referUser = (LinkButton)sender;
        GridViewRow container = (GridViewRow)referUser.NamingContainer;
        SPUser user = SPContext.Current.Web.AllUsers[userloginName]
        // Do something with the user
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.