Home > Sharepoint 2007 > Get SPListItem value using field InternalName

Get SPListItem value using field InternalName

You can get a field value of SPListItem object using its display name like SPListItem[“yourFieldName”] but this does not work always. Because SPListItem indexer require Field Internal name that sharepoint use. Most of the time Display name and internal name is same. but if your display name has some special character in it etc  then sharepoint will keep Internal name different. In any case you should always use Field internal name to get SPListItem column value. This is a best practice
 
 
//Assuming here that you already have your SPWeb object with the variable name web.
SPList yourList = web.Lists["Your list name"];

//Assuming here that you already have your SPLISTItem
//object with the variable name oSPListItem.

string sColumnValue = 
oSPListItem[yourList.Fields["yourSiteColumn display name"].InternalName].ToString();
 
About these ads
Categories: Sharepoint 2007
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: