Nigel Whitworth's Development Site

You are currently not logged in.

Dynamic Combo

In the old ASP method for doing lists/combo boxes was to have a <Select /> tag with a list of items ( Options ) underneath. The new method simplifies things a little. You build up an array list and then bind the array list to a server list as in the following example.

<html>
<head>
    <script language="VB" runat="server">
        Sub Page_Load(sender As Object, e As EventArgs) 
            If Not IsPostBack Then
                    ' Don't want to add items to the list.
                Dim values as ArrayList= new ArrayList()
                    ' Build up the array ( values ) using the method .ADD 
                DropDown1.DataSource = values
                DropDown1.DataBind
            End If
        End Sub
        Sub SubmitBtn_Click(sender As Object, e As EventArgs)
           Label1.Text = "You chose: " + DropDown1.SelectedItem.Text
        End Sub
    </script>
</head>
<body>
    <h3><font face="Verdana">DataBinding DropDownList</font></h3>
    <form runat=server>
        <asp:DropDownList id="DropDown1" runat="server" />
        <asp:button Text="Submit" OnClick="SubmitBtn_Click" runat=server/>
        <p><asp:Label id=Label1 font-name="Verdana" font-size="10pt" runat="server" /> </p>
    </form>
</body>
</html>

 



If you intend to vote or make a comment, please enter the security code.

Make a comment

*Comments are the views of individuals, they may or may not be correct.
All comments are reviewed and accepted or rejected.
If you give an email address, you will be sent an email when someone makes a comment on this page.*

Name :
Email :
Comments :


Only name and Code is compulsory.
 
 
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)