C
Chris
Hi,
When choosing a value in the dropdownlist, i try to put that selectedvalue
in the label, but i always get the first value 'a'.
EnableViewState is by default set to true, so ... what's wrong in my code?
Thanks
Chris
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim ddl As New DropDownList
Dim z As ListItem
Dim kz As String
ddl.AutoPostBack = True
form1.Controls.Add(ddl)
If Page.IsPostBack Then
kz = ddl.SelectedValue
Label1.Text = kz
Else
z = New ListItem("a", "a")
ddl.Items.Add(z)
z = New ListItem("b", "b")
ddl.Items.Add(z)
z = New ListItem("c", "c")
ddl.Items.Add(z)
End If
End Sub
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" ></asp:Label>
</form>
When choosing a value in the dropdownlist, i try to put that selectedvalue
in the label, but i always get the first value 'a'.
EnableViewState is by default set to true, so ... what's wrong in my code?
Thanks
Chris
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim ddl As New DropDownList
Dim z As ListItem
Dim kz As String
ddl.AutoPostBack = True
form1.Controls.Add(ddl)
If Page.IsPostBack Then
kz = ddl.SelectedValue
Label1.Text = kz
Else
z = New ListItem("a", "a")
ddl.Items.Add(z)
z = New ListItem("b", "b")
ddl.Items.Add(z)
z = New ListItem("c", "c")
ddl.Items.Add(z)
End If
End Sub
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" ></asp:Label>
</form>