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?


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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