在radiobuttonlist中添加multiview

时间:2013-11-09 09:25:15

标签: c# asp.net jradiobutton 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>

if (lstTrip.SelectedValue.ToLower() == "roundtrip")
{
    //Change the selected multiview index 
    MultiView1.ActiveViewIndex = 1;
} 
else 
{
    MultiView1.ActiveViewIndex = 0;
}
  

我已经提供了我的asp代码和.cs代码。首先我只有两个视图,这是单向和往返,现在我想为多元素按钮添加一个视图,所以我将如何从我的视图中删除该视图.cs代码,我必须在给定的.cs code.PLZZZ帮助中做出哪些更改

2 个答案:

答案 0 :(得分:1)

在页面加载中写下

    protected void Page_Load(object sender, EventArgs e)
{

      if (!IsPostBack)
        {
            MultiView1.ActiveViewIndex = 1;  //index of the view1

           }
}

答案 1 :(得分:0)

将您的.cs代码更改为以下内容并尝试。

if (lstTrip.SelectedValue.ToLower() == "roundtrip")
{
   //Change the selected multiview index 
MultiView1.ActiveViewIndex = 1;
} 
else if(lstTrip.SelectedValue.ToLower() == "multicity")
{
    MultiView1.ActiveViewIndex = 2;
}
else 
{
    MultiView1.ActiveViewIndex = 0;
}