hyperlink column and a user column

 

To Store values to User Field and URL Field, we have to store in different format.
Because the The User Field is a Lookup Field, getting value from User Information List. The URL Field contains two values, one for URL and another one for URL Description.

User Field Format:   [ID];#[User Login Name]
URL Field Format :   [URL], [URL Description]  // 逗号后有一空格,给其赋值时需小心

Below i give the sample code for addng new list item with URL and User Fields,

UserGroupWebService.UserGroup ugService=new UserGroupWebService.UserGroup();
ListsWebService.Lists lService=new ListsWebService.Lists();

//Get User ID from User Login Name
            XmlNode ugNode=ugService.GetUserInfo("Server\\LoginName");
            XmlDocument ugdoc = new XmlDocument();
            ugdoc.LoadXml(ugNode.OuterXml);
            XmlNodeList ugList = ugdoc.GetElementsByTagName("User");
            string id = ugList[0].Attributes["ID"].Value;

//Build the xml for adding new list item
            string strBatch = @"<Method ID='1' Cmd='New'>
                                <Field Name='Title'>Sample Title</Field>
                                <Field Name='UserName'>" + id + @";#SERVER\\LoginName</Field>
                                <Field Name='SampleUrl'>http://www.microsoft.com, Microsoft Site</Field>
                                </Method>";
            XmlDocument xmlDoc = new System.Xml.XmlDocument();
            System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch");
            elBatch.InnerXml = strBatch;
            //Addding item to the List
            XmlNode ndReturn = lService.UpdateListItems("<List Name>", elBatch);



Before coding add the (~site/_vti_bin/Lists.asmx and ~site/_vti_bin/UserGroup.asmx)  webservices as references.

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/10f4b69a-1d2e-45b3-a427-b9b6c12a86fc

 

SPFieldUrl.DisplayFormat

<Field ID="{c29e077d-f466-4d8e-8bbe-72b66c5f205c}"Name="URL" 
SourceID="http://schemas.microsoft.com/sharepoint/v3"StaticName="URL"  
Group="Base Columns"Type="URL"DisplayName="URL"ColName="nvarchar3"  
RowOrdinal="0"ColName2="nvarchar4"RowOrdinal2="0"Format="Image"Version="1"/> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值