0
我想設置我的ASP.NET DropDownList的默認值等於DropDownList中的一個值。例如,我的列表中填充了〜ALL〜,BrickandMortar,Distribution,Employee,Partner,Premier,Retail和Wholesale,我希望下拉菜單的默認值爲Retail。我曾嘗試這個代碼在我的網頁加載功能:如何在ASP.NET DropDownList控件中將默認值設置爲從SQL數據源中提取的某個值?
if (CustomerClassList != null)
{
CustomerClassList.SelectedValue = CustomerClassDropDrown.Items.FindByValue("Retail").Value;
}
我也把我這行代碼在我的課開始
DropDownList CustomerClassList = new DropDownList();
所以我又回到錯誤的是,有沒有對象引用,所以我不知道該怎麼做。請幫忙!