开发者

SharePoint WebService: Get List Item Navigation URL

I'm using the sharepoint's web service (GetListItems) method to get some fields data for list's items, now in addition for the information that i retrieve for an item I need its direct URL, so i can give the user an optional link to click in order to navigate smoothly to that item in the sharepoint website

here is my code that get's the item's data

 XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
                XmlNode ndViewFields =
                    xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
                XmlNode ndQueryOptions =
                    xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

                var cc = new CredentialCache();
                cc.Add(
                      new Uri(url),
                      "NTLM",
                      new NetworkCredential(username, password, domain));
                SPListWebService.Credentials = cc;
                SPListWebService.Url = url + "/_vti_bin/Lists.asmx";


                //Query Options Node
                ndQueryOptions.InnerXml =
                    "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
                    "<DateInUtc>TRUE</DateInUtc>";
                //Qyery node
                foreach (DataRow row in view.Rows)
                {
                    string v = row[ffdmn].ToString();
                    ndQuery.InnerXml = string.Format("<Where><Eq><FieldRef Name='{0}'/>" +
                   "<Value Type='Text'>{1}</Value></Eq></Where>", sfdmname, v);

                    XmlNode ndListItems =
                        SPListWebService.GetListItems(listName, null, ndQuery,
                        ndViewFields, null, ndQueryOptions, null);

                    foreach (XmlNode node in ndListItems.ChildNodes)
                    {
                        if (node.Name == "rs:data")
                            foreach (XmlNode innerNode in node.ChildNodes)
                                if (innerNode.Name == "z:row")
                                {
                                   //I do some logic here to get the targeted fields
                                }
                    }
                }

Any help?开发者_StackOverflow中文版


Does ows_EncodedAbsUrl work?

innerNode.Attributes["ows_EncodedAbsUrl"].Value

http://blogs.msdn.com/b/sowmyancs/archive/2007/09/15/how-to-download-files-from-a-sharepoint-document-library-remotely-via-lists-asmx-webservice-sps-2003-moss-2007.aspx

EDIT

Okay that works for document libraries, but for lists I think you are going to have to build the url.

First you need to load the list to get its url. (only do this once outside the for loop)

XmlNode ndList = SPListWebService.GetList("Driving License");

Then build the url per row.

string clickurl = url + ndList.Attributes["RootFolder"].Value + "/DispForm.aspx?ID=" + innerNode.Attributes["ows_ID"].Value

Check that there are enough '/'s

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜