EnableViewState And DROPDOWNLIST

T

Tom

<%@ Page Language="vb" AutoEventWireup="false"
EnableViewState="false" .... %>

<FORM id="frmMyForm" method="post" runat="server">
1) Inline Items (In aspx File) :
<ASP:DROPDOWNLIST id="drpStatesOne" runat="server"
enableviewstate="false">
<ASP:LISTITEM value="1">A</ASP:LISTITEM>
<ASP:LISTITEM value="2">B</ASP:LISTITEM>
<ASP:LISTITEM value="3">C</ASP:LISTITEM>
<ASP:LISTITEM value="4">D</ASP:LISTITEM>
</ASP:DROPDOWNLIST>
<BR>
2) Items added in Page_Init Event :
<ASP:DROPDOWNLIST id="drpStatesTwo" runat="server"
enableviewstate="false">
</ASP:DROPDOWNLIST>
<BR>
3) Items added in Page_Load Event :
<ASP:DROPDOWNLIST id="drpStatesThree" runat="server"
enableviewstate="false">
</ASP:DROPDOWNLIST>
<BR>
<INPUT type=submit value="Check It">
</FORM>

Code Behind ....

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
With drpStatesTwo
.Items.Add("A")
.Items.Add("B")
.Items.Add("C")
.Items.Add("D")
End With
End Sub

Protected drpStatesOne As
System.Web.UI.WebControls.DropDownList
Protected drpStatesTwo As
System.Web.UI.WebControls.DropDownList
Protected drpStatesThree As
System.Web.UI.WebControls.DropDownList
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
With drpStatesThree
.Items.Add("A")
.Items.Add("B")
.Items.Add("C")
.Items.Add("D")
End With
End Sub
 
T

Tom

the problem ....
(sorry in last post i just put code)
Every where the EnableViewState property is set
to "false", but still the state (The Item user selects
remain selected even after submitting the form) for first
and second dropdown list.
Expert comments needed.
Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top