-2
我得到NullReferenceException在下面的代碼中由用戶代碼未處理。NullReferenceException未被用戶代碼未處理 - 未將對象引用設置爲對象的實例
if (item["Area"] != null)
{
drpArea.Items.FindByText(item["Area"].ToString()).Selected = true;//error occurs here.
}
試圖找出100萬次。但我無法做到。
的[什麼是.NET一個NullReferenceException?](HTTP可能重複:// stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net) – 2012-04-13 04:17:21
我認爲你需要在drpArea.Items.FindByText(item [「Area」]。ToString())中測試null。甚至可能是drpArea的Items屬性。我不知道那個變量引用的類型。 – Roman 2012-04-13 08:59:11