开发者

Sharepoint + Value does not fall within the expected range + SPListItem

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 withi开发者_如何学Cn the expected range

Looks like there is something with the display vs internal name of the column. Can someone help me with this? Thanks.


Try "Project_x0020_Description". AFAIK this works when using the web services. Not sure whether it also helps in your case.

Here is some more information: http://www.davehunter.co.uk/Blog/Lists/Posts/Post.aspx?ID=95


Use Always the URl of the List, because URL's dont give problems like that ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜