Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to get a value of a lookup field to be populated in a datatable

$
0
0

I have the following script that I am trying to use the results to populate a piechart. However the lookup field called CountTask is preventing the populating of the chart as it is looking for a string(numbers are in that field but in my first test I used the title field so I know that string will work)

How do I output the lookup field value of that item?  Your help is greatly appreciated.

ClientContext context = newClientContext("http://*******/sites/C***C");

                List lstOReq = context.Web.Lists.GetByTitle("EnhancementStatus");

                CamlQuery oquery =newCamlQuery();

                oquery.ViewXml ="<View><RowLimit>100</RowLimit></View>";

                ListItemCollection items = lstOReq.GetItems(oquery);

                context.Load(lstOReq);

                context.Load(items);

                context.ExecuteQuery();

                DataTable otable =newDataTable();

                otable.Columns.Add("Id");

                otable.Columns.Add("Title");

                otable.Columns.Add("CountTask");

               foreach(ListItem iteminitems)

                    otable.Rows.Add(item.Id, item["Title"], item["CountTask"]);

                    AEStatus.DataSource = otable;

                AEStatus.DataBind();

Thank you


IPW


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>