I have an Item in sitecore with id '{05B1C498-39D1-40D6-B454-2A3277A6DDF9}' which has one language version in "en" and one in "da-DK" .
For this Item there is a field "Test" with type text, In English version I have saved "English Text" in this field. And for Danish version of above item I have saved "Danish Text" in the field "Test".
I want to get the the above item in Danish language. I used this code:
string dicItemId= "{05B1C498-39D1-40D6-B454-2A3277A6DDF9}"
Item dictionaryItem = Context.Database.GetItem(dicItemId, Sitecore.Data.Managers.LanguageManager.GetLanguage("da-DK"));
lblTest.Text = dictionaryItem["Test"];
I am expecting to see the string "Danish Text" for the above label. But somehow its not getting the Danish version and output is "English Text".
I also tried to get the version of above item in a language whose version does not exist in my Sitecore, I tried with:
Item dictionaryItem = Context.Database.GetItem(dicItemId, Sitecore.Data.Managers.LanguageManager.GetLanguage("nl-NL"));
I was expecting the dictionaryItem as null but still it contains the item with id '{05B1C498-39D1-40D6-B454-2A3277A6DDF9}'

contextDatabase.GetItem(dicItemId, Sitecore.Data.Managers.LanguageManager.GetLanguage("da")). And It worked now. But when I use "da-DK" then it doesn't work. - Kamran