lvResult is a list witin my client application that i created: here im populating the client list from a list witin sharepoint using the field names using a loop as i wanted to return all fields.
private void getListDetails(string zoneName)
{
lvResult.Items.Clear();
try
{
ClientContext context = new ClientContext(txtURL.Text);
List list = context.Web.Lists.GetByTitle(zoneName);
CamlQuery query = new CamlQuery();
query.ViewXml = "<View/>";
ListItemCollection items = list.GetItems(query);
context.Load(list);
context.Load(items);
context.ExecuteQuery();
foreach (ListItem item in items)
{
ListViewItem fitems = new ListViewItem((String)item["Title"]);
fitems.SubItems.Add((String)item["ImageUrl"]);
fitems.SubItems.Add((String)item["NavigationUrl"]);
fitems.SubItems.Add(item["OpenInNewWindow"].ToString());
//add the items to the list
lvResult.Items.Add(fitems);
}
}
catch (Exception a)
{
MessageBox.Show(a.ToString());
}
}
for you, you can do the same above or somthing on the lines of:
foreach (ListItem item in items)
{
string fieldValue = item.FieldValuesAsText["field name"];
}
if you know the index order of each row say you only want to return the first item row than there is no need for a foreach:
string fieldValue = items[0].FieldValuesAsText["field name"];