如果选择第一个,我想显示第二个drp值

时间:2015-05-31 16:58:28

标签: c# asp.net

我有两个问题:

1)如果第一次下降,我想显示第二次下拉的值     选择了下降值

2)我想在第一个中传递所选项的DataFeild值     作为参数下拉到第二个下拉列表。 (它在扔     outofrange例外)

<div class="colmd-3 col-sm-3 col-xs-3 responsive-filterbar">
    <asp:DropDownList runat="server" ID="drpCRHCompetencyName" ClientIDMode="Static" CssClass="form-control" DataTextField="title" DataValueField="responsibilityID"></asp:DropDownList>
</div>
<div class="colmd-3 col-sm-3 col-xs-3 responsive-filterbar">
    <asp:DropDownList runat="server" ID="drpCRHCompetencyLevel" ClientIDMode="Static" CssClass="form-control" DataTextField="level" DataValueField="skillLevleID"></asp:DropDownList>
</div> 

var competencyName = CompetencyManager.GetSFIACompetencies();
drpCRHCompetencyName.DataSource = competencyName;
drpCRHCompetencyName.DataBind();

var competencyLevel = CompetencyManager.GetLevelByCompetency(drpCRHCompetencyName.SelectedValue);
drpCRHCompetencyLevel.DataSource = competencyLevel;
drpCRHCompetencyLevel.DataBind();

如果我把drpCRHCompetencyName.SelectedValue作为参数,我现在收到错误。有人可以建议我正确的方式

1 个答案:

答案 0 :(得分:0)

如果以下行返回任何用于DataBinding的有效对象,则必须首先检查:

var competencyLevel = CompetencyManager.GetLevelByCompetency(drpCRHCompetencyName.SelectedValue);

希望这可能会有所帮助。最好的问候,