[求助]DropDownList的绑定问题
if (id > 0) //修改{
DetailsViewFile.DataSource = MediaFile.GetListByCategoryID(id);
DetailsViewFile.DataBind();
MediaFile file = new MediaFile(id);
MediaCategories category = new MediaCategories(file.CategoryID);
DropDownList ddl = (DropDownList)DetailsViewFile.FindControl ("dropCategory");
ddl.DataSource = MediaCategories.GetInfoByParentID(category.ParentID);
ddl.DataBind();
ddl.SelectedValue = file.CategoryID.ToString();
ViewState.Add("cid", cid);
}
还是这段代码,运行到“ddl.DataSource = MediaCategories.GetInfoByParentID(category.ParentID);”时,提示“未将对象引用设置到对象的实例。”可是,我已经在MediaCategories.cs中定义了GetInfoByParentID这个方法,传入的是ParentID参数,查询出MediaCategories表中的所有字段作为ddl的数据源,不知道是什么原因,请大家帮帮忙!