如何在其他下拉列表中选择项目时在下拉列表中禁用多个项目?

时间:2015-06-26 04:52:44

标签: asp.net c#-4.0

<table>
    <tr>
        <td>
            <asp:Label ID="lblstarttime" runat="server" Text="StartTime :" Style="font-size: 80%; font-weight: bold">
            </asp:Label>
        </td>

        <td>
            <asp:DropDownList ID="DdlStartTime" runat="server" CssClass="dropdown" Style="font-size: small" OnSelectedIndexChanged="DdlStartTime_SelectedIndexChanged">
            </asp:DropDownList>
        </td>

        <td style="width: 10%"></td>

        <td>
            <asp:Label ID="lblEndTime" runat="server" Text="EndTime :" Style="font-size: 70%; font-weight: bold">
            </asp:Label>
        </td>

        <td>
            <asp:DropDownList ID="DdlEndTime" runat="server" CssClass="dropdown" Style="font-size: small">
            </asp:DropDownList>
        </td>

        <td>
            <asp:Button ID="btnsub" runat="server" Text="Submit" CssClass="btn btn-info" OnClick="btnsub_Click" />
        </td>
    </tr>
</table>

protected void DdlStartTime_SelectedIndexChanged(object sender, EventArgs e)
{
    ListItem selectedItem = DdlStartTime.SelectedItem;

    foreach (ListItem item in DdlEndTime.Items)
    {
        if (item.Value == selectedItem.Value)
        {
            DdlEndTime.Items.Remove(item);
        }
    }
}

当我在StartTime中选择DdlStartTime时,endTime项应该大于第二个下拉列表。

在这里,我无法得到我想要的确切内容..任何人都可以帮助我吗?

0 个答案:

没有答案