我需要獲取SplistItem.Item的值。有一個新的屬性添加了「ShortenedUrl」。問題在於,舊網頁不包含此屬性,因此每當網站是舊網頁時,我都會收到「值不在預期範圍內」的錯誤。如何使用SpListItem.Item檢索它之前是否存在屬性
有沒有辦法首先檢查項目是否存在?獲得該值之前是否有 ?
這是我的代碼。
'Set shortened URL
Dim objShortUrl As Object = postItemById.Item("ows_ShortenedUrl")
If objShortUrl IsNot Nothing Then
blogPost.shortURL = objShortUrl
Else
blogPost.shortURL = DBNull.Value
End If
如果「ows_ShortenedUrl」存在,我該怎麼辦?