problem with programmatically designed dropdownlist

D

Dan

Hi,

i defined a dropdownlist in code-behind but i can't get the selectedvalue. I
czn't use autopostback because there are other elements in the form to be
filled.

aspx file:
<asp:DropDownList ID="minw" runat="server">
</asp:DropDownList>

<asp:Button ID="Button1" runat="server" />

code-behind::
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim z As ListItem
minw.Items.Clear()
For i = 0 To 200
z = New ListItem(i, i)
minw.Items.Add(z)
Next
.....

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mi As Integer
mi = minw.SelectedValue
.....

This returns 0 (first value).
Thanks
Dan
 

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