I am trying to get a column value from a SharePoint list and populate it to an ASP text box. I used SPQuery
to filter and get the value. I even mentioned view fields and increased the List View Lookup Threshold. But when I am trying to assign the text box value with the column field, I am getting this exception:
Argument exception was unhandled by user- value does not fall within the expected range.
Is there any workaround for this? Code sample:
SPQuery qrySeriesDesc = new SPQuery();
qrySeriesDesc.Query = "<Where><Eq><FieldRef Name='Series'/><Value Type='Text'>" + SeriesNumber + "</Value></Eq></Where>";
qrySeriesDesc.ViewFields = "<FieldRef Name='Series Description'/>";
SPListItemCollection itemCol = list.GetItems(qrySeriesDesc);
foreach (SPListItem item in itemCol)
{
if (item != null)
{
tboxSeriesDescription.Text = item["Series Description"].ToString();
}
}
I am getting the mentioned exception at:
tboxSeriesDescription.Text = item["Series Description"].ToString();