Agusto Xaverius P Sipahutar

Job:Making some bugs and patch
Moss/Wss,C#,Sql Server,WWF,K2.BlackPearl
Motto : Keep Study and study
See also: Other Geeks@INDC

News




MCP Logo
MCTS Logo

MCP ID# 3542391

My Curiculum Vitae


Agusto Xaverius P S's Facebook profile

Other Article

My Community

My Article/Share Knowledge

Others Moss/Wss Site

My Other Website/Blogs

My Share (Ebook,etc)

Tips on Trick Wss 3.0 - 01

 Bila kita mempunyai suau SPListItem dimana item kita tersebut mempunyai field dengan type person / group untuk mendapatkan user tersebut kita bisa lakukan dengan 2 cara yaitu :

public void GetUser()

{

    SPUser user;

    string s;

    string [] split'

   using (SPSite site = new SPSite("http://portal"))

    {

                using (SPWeb web = site.OpenWeb())

                {

                    SPList list = web.Lists["Example For Users"];

                    SPListItem item = list.Items[0];

                     s =   item["User Name"];

                     split = s.split(';');

                     user = web.Users.GetByID(Convert.ToInt32(split[0]));

                }

     }

}

 

atau dengan cara ini :

 

public void GetUser()

{

 

using (SPSite site = new SPSite("http://portal"))

            {

                using (SPWeb web = site.OpenWeb())

                {

                    SPList list = web.Lists["Example For Users"];

                    SPListItem item = list.Items[0];

 

                    SPFieldUserValue userValue = new SPFieldUserValue(web, item["User Name"].ToString());

                    if (userValue!=null)

                    {

                        user = userValue.user;

                    }

                }

            }

 }

Share this post: | | | |
Posted: May 15 2008, 03:06 PM by agusto | with no comments
Filed under:

Comments

No Comments