我有三个下拉菜单,它们使用存储过程来填充我的网格视图。我需要第一个设施 DropDown 在第二个源类型下拉列表中提供不同的选项,具体取决于选择的设施。有些设施需要查看所有选项,有些只需要 1 或 2 个。我不确定如何去做。
这是下拉菜单和商店程序的代码。
任何帮助将不胜感激
private void BindGrid()
{
//set up arguments for the stored proc
int? FacilityID = (ddlFacility.SelectedValue.Equals("-1")) ? (int?)null : int.Parse(ddlFacility.SelectedValue);
int? SourceTypeID = int.Parse(ddlSource.SelectedValue);
int? StatusTypeID = int.Parse(ddlStatusType.SelectedValue);
//bind
ObjectResult<models.MS_spGetMatchCross_Result> ds = this.DataLayer.model.MS_spGetMatchCross(FacilityID, SourceTypeID, StatusTypeID);
gvResults.DataSource = ds;
gvResults.DataBind();
}
private void ResetForm()
{
try
{
//facility dropdown
ddlFacility.Items.Clear();
ddlFacility.DataSource = this.DataLayer.model.MS_spGetFacilityInfo(null).OrderBy(x => x.FacilityName);
ddlFacility.DataTextField = "FacilityName";
ddlFacility.DataValueField = "FacilityID";
ddlFacility.DataBind();
ddlFacility.Items.Insert(0, new ListItem("Select a facility...", "-1"));
//SourceType dropdown
ddlSource.Items.Clear();
ddlSource.DataSource = this.DataLayer.model.SourceTypes;
ddlSource.DataTextField = "Description";
ddlSource.DataValueField = "SourcetypeID";
ddlSource.DataBind();
//Match Status dropdown
ddlStatusType.Items.Clear();
ddlStatusType.DataSource = this.DataLayer.model.StatusTypes;
ddlStatusType.DataTextField = "Description";
ddlStatusType.DataValueField = "StatusTypeID";
ddlStatusType.DataBind();
BindGrid();
}
catch (Exception ex)
{
this.SetMessage(ex.ToString(), PageMessageType.Error);
AISLogger.WriteException(ex);
}
}