【问题标题】:Populating Items in a dropdown box in asp.net aspx page在 asp.net aspx 页面的下拉框中填充项目
【发布时间】:2013-01-28 22:12:40
【问题描述】:

我有一个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>

我想在下拉框中填充所有这些项目。怎么做。我使用 asp.net 和 vb.net 作为后面的代码。页面加载后,项目必须立即填充到下拉框中。

我还有其他的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>

我需要它在一个下拉框中。

【问题讨论】:

  • 这不是 php 代码,是 html 代码,放在任何地方就可以了。

标签: asp.net


【解决方案1】:

试试这个:

    <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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多