Looks like other people have had this issue, but I would like to understand how to target a column if there are spaces in a list column name when using the code below. Here is what I have:
SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["Project Info"];
SPListItemCollection collItem = oList.GetItems("Project Description");
if (collItem.Count > 0)
{
foreach (SPListItem oItem in collItem)
{
description = oItem["Project Description"].ToString();
}
}
If I create the list field "Project Description" with underscores for the column name (Project_Description), then it works just fine, but with the code above I get an error: Value does not fall within the expected range
Looks like there is something with the display vs internal name of the column. Can someone help me with this? Thanks.