0

At first See the Code below.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test.aspx.vb" Inherits="BLL.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<form id="form1" runat="server">
    <div>
        <asp:Panel ID="pnlCustom" runat="server"></asp:Panel>
        <asp:Panel ID="pnlDiv1" runat="server">
            <asp:DropDownList ID="ddl_Status" runat="server"></asp:DropDownList>
        </asp:Panel>
        <asp:Panel ID="pnlDiv2" runat="server">
            <asp:DropDownList ID="ddlImg1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlImg1_SelectedIndexChanged"></asp:DropDownList>
        </asp:Panel>
        <asp:Panel ID="pnlDiv3" runat="server">
            <asp:DropDownList ID="ddlImg2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlImg2_SelectedIndexChanged"></asp:DropDownList>
        </asp:Panel>
    </div>
</form>
</body>
</html>

I want to hide and show the panel in different order as per the requirement. i don't want to change the content of the panel. pnlDiv1,pnlDiv2,pnlDiv3 will bind in pnlCustom.

Now, In Page_Load Event i am setting all panel style to "display:none" except "pnlCustom" and dynamically adding pnlDiv1/pnlDiv2/pnlDiv3 in "pnlCustom" and set its style to "display:inline".

In my application problem is If i change the value of "ddlImg1" the page gets postback and all the value reset. this is same for the "ddlImg2".

Note:Values are bind in dropdown in Page_Load if its not postback.. so, anyone can explain what's an issue?

Sagar Rawal
  • 1,442
  • 2
  • 12
  • 39

1 Answers1

0

This could be a possible issue with the ViewState.

The following link might be helpful to you:

ASP.NET DropDownList not retaining selected item on postback

Community
  • 1
  • 1
Siva Gopal
  • 3,474
  • 1
  • 25
  • 22