【发布时间】:2011-05-10 12:05:14
【问题描述】:
我有一个在 Page_Load 事件中填充的 ASP DropDownList,在我选择一个项目并点击一个按钮后,选定的项目被清除并且 DropDownList 中的第一个项目被选中。 (DropDownList 仅在页面未回发时填充)
if (!IsPostBack)
{
List<Country> lCountries = new List<Country>();
List<CompanySchedule> lCompanySchedules = new List<CompanySchedule>();
this.Load_Countries(lCountries);
this.Load_Schedules(lCompanySchedules);
if (personnelRec == null)
{
personnelRec = new Personnel();
}
if (Request.QueryString["UA"] != null && Convert.ToInt32(Request.QueryString["UA"].ToString()) > 0)
{
userAccount.ID = Convert.ToInt32(Request.QueryString["UA"].ToString());
App_Database.Snapshift_Select_Helper.SNAPSHIFT_SELECT_PERSONNEL_APP_ACCOUNT(ref userAccount);
}
this.imgEmployeePicture.ImageUrl = "./images/Employees/nophoto.gif";
if (Request.QueryString["EI"] != null && Convert.ToInt32(Request.QueryString["EI"].ToString()) > 0)
{
this.Load_PersonnelRec(Convert.ToInt32(Request.QueryString["EI"].ToString()));
}
else
{
this.lblChangeDirectionHead.Enabled = false;
this.lblChangeDirections.Enabled = false;
this.lbSchedules.Disabled = true;
}
}
【问题讨论】:
-
请发布您的 Page_Load 事件的代码。这将有助于回答。
-
您的人口代码周围是否有“if (!IsPostBack)”?
-
我在您的代码中没有看到 DropDownList。是通过
this.Load_Countries(lCountries);完成的吗?另外,您要在哪里获取所选值? -
是的,我在 Load_XXXX 函数中加载下拉列表。我正在尝试在保存函数中获取所选值
标签: asp.net drop-down-menu postback selection