SharePoint Web services - get choice field values Using GetList() method
Below is the code to get the values of a choice field in a sharepoint list . You can save these values into a datatable and can bind the datatable with a Drop-down control.
//get choice field values from sharepoint list
protected void GetDrpDownValuesFromList()
{
SPWebservice.Lists FMService = new SPWebservice.Lists();
FMService.Credentials = System.Net.CredentialCache.DefaultCredentials;
XmlNode ndLists = FMService.GetList("MyList"); //add list name
XmlDocument doc = new XmlDocument();
doc.LoadXml(ndLists.OuterXml);
XmlNamespaceManager mg = new XmlNamespaceManager(doc.NameTable);
mg.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
mg.AddNamespace("z", "#RowsetSchema");
mg.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
mg.AddNamespace("y", "http://schemas.microsoft.com/sharepoint/soap/ois");
mg.AddNamespace("w", "http://schemas.microsoft.com/WebPart/v2");
mg.AddNamespace("d", "http://schemas.microsoft.com/sharepoint/soap/directory");
XmlNodeList FieldsInList = doc.SelectNodes("//sp:Field", mg);
foreach (XmlNode Field in FieldsInList)
{
if (Field.HasChildNodes)
{
if (Field.Attributes["Name"].Value == "choiceFieldName")
{
foreach (XmlNode node in Field.ChildNodes)
{
if (node.HasChildNodes)
{
foreach (XmlNode Newnode in node.ChildNodes)
{
if(Newnode.HasChildNodes)
{
_addToDataTable(Newnode.InnerText); // Add node value to datatable
} } } } } } } }
//get choice field values from sharepoint list
protected void GetDrpDownValuesFromList()
{
SPWebservice.Lists FMService = new SPWebservice.Lists();
FMService.Credentials = System.Net.CredentialCache.DefaultCredentials;
XmlNode ndLists = FMService.GetList("MyList"); //add list name
XmlDocument doc = new XmlDocument();
doc.LoadXml(ndLists.OuterXml);
XmlNamespaceManager mg = new XmlNamespaceManager(doc.NameTable);
mg.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
mg.AddNamespace("z", "#RowsetSchema");
mg.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
mg.AddNamespace("y", "http://schemas.microsoft.com/sharepoint/soap/ois");
mg.AddNamespace("w", "http://schemas.microsoft.com/WebPart/v2");
mg.AddNamespace("d", "http://schemas.microsoft.com/sharepoint/soap/directory");
XmlNodeList FieldsInList = doc.SelectNodes("//sp:Field", mg);
foreach (XmlNode Field in FieldsInList)
{
if (Field.HasChildNodes)
{
if (Field.Attributes["Name"].Value == "choiceFieldName")
{
foreach (XmlNode node in Field.ChildNodes)
{
if (node.HasChildNodes)
{
foreach (XmlNode Newnode in node.ChildNodes)
{
if(Newnode.HasChildNodes)
{
_addToDataTable(Newnode.InnerText); // Add node value to datatable
} } } } } } } }
Your post is very informative. You have written it very well. I will keep on coming here to check new updates. Thanks for sharing this article.
ReplyDeletehow to write a dissertation
Thanks for writing Informative Blog. I always read from here.
ReplyDeleteThanks for sharing the post. Can SharePoint be helpful for my essay writing website?
ReplyDeleteFinding the job in business that is a good fit for your skills in these days can be tough. A slow job market and recent economic troubles have piled the job applications and resumes up in almost every human resources department.
ReplyDeleteengineer expert assignment
Adobe is a trusted name that will help to speak loudly for your abilities. In fact, many employers use resume reading software that sorts out all the applicants who specifically have ACE Certification and discards those who don't.
ReplyDeletehelp with algebra homework
Many of the really good and quality ideas on writing and checking of the thesis writing service malaysia writing are pointed in this article. Thank you for such a great step to step instruction that can be used for any type of article. For example, if you are going to work on the scientific one, you can be sure, that the first part will disclose the introduction in such a paper as well as any belles-lettre one. Surely, there are a lot of other differences, like the terms characteristics only for the mentioned type of style. But the main principles are the same.
ReplyDeletesay
ReplyDelete