18 July 2013

SharePoint-GridView & PeopleEditor control.

Developer usually invest much time when the control are sharepoint and binding data is not made straight forward.

Below is simple example to get SharePoint:PeopleEditor control in SPGridView Control on application page.

Step 01:  Add SPGridView control on Application /Webpart page.
Step 02:  Add needed columns in the Sp GridView
Step 03 : Add Sharepoint PeopleEditor column
Step 04:  Add Title Property in PeopleEditor with binded column from data source
 Ex: -   Title='<%# Bind("AUTHOR") %>'
Step 05: Add OnRowDataBound property in SPGridView
Ex : - OnRowDataBound="spGridViewRowEventHandler"
Step 06: Add your picker validate code to resolve the user/Author on databound.

protected void spGridViewRowEventHandler(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                PeopleEditor ppAuthor = (PeopleEditor)e.Row.FindControl("Control");
                string userid= ppAuthor.Title.ToString();
                 ppAuthor.CommaSeparatedAccounts =userid


That's it your control is done

Rate Now: