這段代碼給我空數據庫如何從DropDownList的數據插入到數據庫的ASP C#
cmd2.Parameters.AddWithValue("@Fk_CatID", DropDownListCategory.SelectedItem.Value);
這個代碼給我空數據庫
string queryCategory = "select CatName from CategoryItemsTBL";
DataTable dtCategory = GetDataCategory(queryCategory);
DropDownListCategory.DataSource = dtCategory;
DropDownListCategory.DataTextField = "CatName";
DropDownListCategory.DataValueField = "CatName";
DropDownListCategory.DataBind();
顯示您的完整代碼。你在DropDownListCategory.SelectedItem.Value中得到什麼 – DevelopmentIsMyPassion
沒有更多的信息就無法說出你的代碼有什麼問題。在[如何問]上鎖定(https://stackoverflow.com/help/how-to-ask)。 「DropDownListCategory.SelectedItem.Value」的值是什麼? –
你有沒有試過'DropDownListCategory.SelectedValue'? –