我有問題從FIndControl函數獲取dropdownlist的值。幫助:無法投出對象Dropdownllist到IConvertible
這裏是代碼我想使用:
currentCategoryID = Convert.ToInt32(((DropDownList)r.FindControl("DDLCategories")));
的currentCategoryID在數據庫中的值是一個「INT」
當我執行上面的代碼我收到此錯誤信息:
無法投射「System.Web.UI.WebControls.DropDownList」類型的對象以鍵入「System.IConvertible」。
使用相同的代碼,我不得不使用此代碼retireve文本框的值,一切都OK
currentAddress = ((TextBox)r.FindControl("txtAddress")).Text;
可能有人請指出我如何編寫這段代碼正確
謝謝沃爾特,我知道這是簡單的東西,我正在努力。 – Jason 2009-04-11 22:53:14