使用以下代码时,会返回此错误: “rblPermisSejourA”有一个无效的 SelectedValue,因为它不存在于项目列表中。
<asp:RadioButtonList ID="rblPermisSejour" runat="server"
DataSourceID="EntityDataSourcePermisSejour" DataTextField="Libelle"
DataValueField="Id" AppendDataBoundItems="True" RepeatDirection="Horizontal">
<asp:ListItem Selected="True" Text="" Value="-1">Aucun</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="rblPermisSejourA" runat="server"
DataSourceID="EntityDataSourcePermisSejour" DataTextField="Libelle"
DataValueField="Id" AppendDataBoundItems="True" RepeatDirection="Horizontal">
<asp:ListItem Selected="True" Text="" Value="-1">Aucun</asp:ListItem>
</asp:RadioButtonList>
protected void ws2_OnDeactivate(object sender, EventArgs e)
{
rblPermisSejourA.SelectedValue = rblPermisSejour.SelectedValue;
}
请注意,“rblPermisSejour”在一个向导步骤中,“rblPermisSejourA”在另一个尚未激活的向导步骤中(没有 id 和没有标题,女巫中有“rblPermisSejourA”)。激活此步骤后,一切正常。
但是使用与另一个 RadioButtonList 相同的代码和相同的操作,它运行良好,并且在相同的上下文中(未激活向导步骤)。