开发者

page strange behavior

I face so strange action in my page.

I have a radio button list, according to the selection i execute specific code.

The problem is:

for example when i select option 2 then i select back option 1.

the page maintains the state(all the drop down lists maintain their previous selections) and i need to click the link one more time to force the page to enter this condition:

if (!Page.IsPostBack)
{
    BindCamp(0);
    BindCamp(1);
}

my aspx :

<asp:RadioButtonList ID="rbl" runat="server"
     OnSelectedIndexChanged="rbl_SelectedIndexChanged"
     RepeatDirection="Horizontal" Width="200px" AutoPostBack="True">
  <asp:ListItem Value="0" Selected="True">view data</asp:ListItem>
  <asp:ListItem Value="1">view report</asp:ListItem>
</asp:RadioButtonList>

My code:

 protected void rbl_SelectedIndexChanged(object sende开发者_如何学Cr, EventArgs e)
 {
     if (rbl.SelectedItem.Value == "0")
     {
         pnl_view.Visible = true;
         pnl_stat.Visible = false;
         pnl_rep.Visible = false;
     }
     else
     {
         pnl_view.Visible = false;
         pnl_all.Visible = false;
         pnl_Dean.Visible = false;
         pnl_research.Visible = false;
         pnl_stat.Visible = true;
     }
 }


Per your comments, DLL's will always retain their values unless you manually set the selection, you set EnableViewState="false" (which disabled all viewstate then). So I think you may need code that does:

ddl.SelectedIndex = 0; // or -1 depending on whether you want an item selected

Upon clicking the next radio button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜