0
<asp:MultiView ID="MultiView1" runat="server">
    <asp:View ID="View1" runat="server">
      </asp:View>
 <asp:View ID="View2" runat="server" >
 <table class="style1" style="border: medium groove #808080">
 ......contents.....
</asp:view>


protected void ddlto_SelectedIndexChanged(object sender, EventArgs e)
{

}
protected void RadioButton1_CheckedChanged1(object sender, EventArgs e)
{
    MultiView1.ActiveViewIndex = 0;
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
    MultiView1.ActiveViewIndex = 2;
}

<asp:RadioButtonList ID="RadioButtonList2" runat="server" AutoPostBack="True" 
                                            RepeatDirection="Horizontal" Font-Names="Arial" Font-Size="Small" 
                                            onselectedindexchanged="MultiView1_ActiveViewChanged">
                                            <asp:ListItem Selected="True">One Way</asp:ListItem>
                                            <asp:ListItem>Round Trip</asp:ListItem>
                                            <asp:ListItem>Multi City</asp:ListItem>


                                        </asp:RadioButtonList>

我有一个单选按钮单向列表,单向,往返和多城市,我采取了多视图,在视图 2 中我添加了代码代码,并且我想在单击第二个单选按钮时显示该代码,即往返,怎么办。请帮忙

4

1 回答 1

0

我将假设从您添加的代码中,您希望Round Trip项目成为更改多视图视图的项目。您在 RadioButtonList 上设置事件处理程序的方式是错误的。您无法处理带有单选按钮列表的ActiveViewChanged处理程序。MultiView

最好的办法是像这样向您的单选按钮列表添加更多内容

<asp:RadioButtonList ID="lstTrip" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" Font-Names="Arial" Font-Size="Small" onselectedindexchanged="lstTrip_SelectedIndexChanged">
    <asp:ListItem Selected="True" Value="OneWay">One Way</asp:ListItem>
    <asp:ListItem Value="RoundTrip">Round Trip</asp:ListItem>
    <asp:ListItem Value="MultiCity">Multi City</asp:ListItem>
</asp:RadioButtonList>

然后像你一样处理 SelectedIndexChanged 上的事件

protected void lstTrip_SelectedIndexChanged(object sender, EventArgs e)
{
    if (lstTrip.SelectedValue.ToLower() == "roundtrip")
    {
        //Change the selected multiview index 
        MultiView1.ActiveViewIndex = 1;
    } 
    else 
    {
        MultiView1.ActiveViewIndex = 0;
    }
}

您确实需要考虑更具描述性地命名您的控件,就好像其他人要查看您的代码一样,他们将很难理解它并可能维护它。

于 2013-11-08T13:01:15.557 回答