<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>

i have a radiolist of thre buttons-one way,round trip and multicity, i have taken a multiview in which in view 2 i have added the codes codes,and i want to show that code when i click on the 2nd radio button i.e on round trip,how to do it. plzz help

有帮助吗?

解决方案

I'm going to assume that from the code you've added you want the Round Trip item to be the one that changes the view of your multiview. The way you have the event handler set up on your RadioButtonList is wrong. You can't handle a ActiveViewChanged handler on a MultiView with a radio button list.

The best thing is to add more to your radio button list like so

<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>

Then just handle the event on the SelectedIndexChanged like you did

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;
    }
}

You really need to consider naming your controls more descriptively as if anyone else were to look at your code, they would have a hard time understanding it and potentially maintaining it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top