简体   繁体   English

在ASP.NET ASPX页面的下拉框中填充项目

[英]Populating Items in a dropdown box in asp.net aspx page

I have a php code 我有一个PHP代码

- --

---------
<div id="product1">
<select name="product" class=":required" onchange="change1(this.value)">
<option value="" selected="selected">Select Product</option>
<option value="10">
Almond </option>
<option value="18">
Capsicum </option>
<option value="3">
Cashew </option>
<option value="1">
Cocoa </option>
<option value="2">
Coffee </option>
<option value="4">
Cotton </option>
<option value="16">
Garlic </option>
<option value="13">
Grains </option>
<option value="22">
Groundnut </option>
<option value="17">
Onion </option>
<option value="19">
Parsley </option>
<option value="9">
Peanut </option>
<option value="7">
Pepper </option>
<option value="11">
Pulses </option>
<option value="5">
Rice </option>
<option value="6">
Sesame </option>
<option value="8">
Spice </option>
<option value="14">
Sugar </option>
<option value="15">
Tomato </option>
<option value="12">
Wool </option>
<option value="23">
_ Other _ </option>
</select>
</div>

I want to populate all those items in a drop down box. 我想在一个下拉框中填充所有这些项目。 How to do it. 怎么做。 I am using asp.net and vb.net as code behind. 我使用asp.net和vb.net作为后面的代码。 As soon as page loads, the items must populate in the dropdownbox. 页面加载后,所有项目都必须在下拉框中填充。

I have other php code 我还有其他的php代码

<tr>
<td align="right">Select Region:</td>
<td align="left" class="red"><select onchange="xajax_SelectCountry(this.value);" name="region" class=":required" id="region">
<option value="" selected="selected">Select Region</option>
<option value="Asia" >
Asia </option>
<option value="Australia and Oceania" >
Australia and Oceania </option>
<option value="Central Africa" >
Central Africa </option>
<option value="East Africa" >
East Africa </option>
<option value="Europe" >
Europe </option>
<option value="North Africa" >
North Africa </option>
<option value="North America" >
North America </option>
<option value="South America" >
South America </option>
<option value="Southern Africa" >
Southern Africa </option>
<option value="West Africa" >
West Africa </option>
</select></td>
</tr>
<tr>

I need it in a dropdown box . 我需要一个下拉框。

Try this: 尝试这个:

    <asp:DropDownList runat="server" ID="ddl1">
        <asp:ListItem Value="Select Product" Selected="True"></asp:ListItem>
        <asp:ListItem Value="10" Text="Almond"> </asp:ListItem>
        <asp:ListItem Value="18" Text="Capsicum"> </asp:ListItem>
        <asp:ListItem Value="3" Text="Cashew"> </asp:ListItem>
        <asp:ListItem Value="1" Text="Cocoa"> </asp:ListItem>
        <asp:ListItem Value="2" Text="Coffee"> </asp:ListItem>
        <asp:ListItem Value="4" Text="Cotton"> </asp:ListItem>
        <asp:ListItem Value="16" Text="Garlic"> </asp:ListItem>
        <asp:ListItem Value="13" Text="Grains"> </asp:ListItem>
        <asp:ListItem Value="22" Text="Groundnut"> </asp:ListItem>
        <asp:ListItem Value="17" Text="Onion"> </asp:ListItem>
        <asp:ListItem Value="19" Text="Parsley"> </asp:ListItem>
        <asp:ListItem Value="9" Text="Peanut"> </asp:ListItem>
        <asp:ListItem Value="7" Text="Pepper"> </asp:ListItem>
        <asp:ListItem Value="11" Text="Pulses"> </asp:ListItem>
        <asp:ListItem Value="5" Text="Rice"> </asp:ListItem>
        <asp:ListItem Value="6" Text="Sesame"> </asp:ListItem>
        <asp:ListItem Value="8" Text="Spice"> </asp:ListItem>
        <asp:ListItem Value="14" Text="Sugar"></asp:ListItem>
        <asp:ListItem Value="15" Text="Tomato"> </asp:ListItem>
        <asp:ListItem Value="12" Text="Wool"> </asp:ListItem>
        <asp:ListItem Value="23" Text="_ Other _"></asp:ListItem>
    </asp:DropDownList>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM