gpt4 book ai didi

c# - 如何将标准值放在下拉列表顶部

转载 作者:行者123 更新时间:2023-12-02 17:59:17 25 4
gpt4 key购买 nike

我的下拉列表将填充来自实体模型的数据,如下所示:

    HotelTestDatabaseEntities hotelData = new HotelTestDatabaseEntities();
var afdelingQuery = from afd in hotelData.Afdelings
orderby afd.afdelingNaam
select afd;
DropDownList1.DataValueField = "afdelingID";
DropDownList1.DataTextField = "afdelingNaam";
DropDownList1.DataSource = afdelingQuery;
DataBind();

如何将“选择值...”项放在下拉列表的顶部?

最佳答案

在 DropDownList1 绑定(bind)完成后添加此代码。

DropDownList1.Items.Insert(0,new ListItem("Please Select One","0"));

关于c# - 如何将标准值放在下拉列表顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11011554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com