我想在dropdownlist中显示的数据库中提取的其他记录之上添加“全部”选项。关于如何在vb.net 2005中执行此操作的想法?
答案 0 :(得分:1)
考虑问题。不是将项添加到组合框,而是将项添加到动态数据源。
答案 1 :(得分:0)
即使在VS 2005中,AppendDataBoundItems
属性也可用。因此,您可以在aspx上以编程方式或声明方式以编程方式添加此项目:
<asp:DropDownList
runat="server"
ID="DropDownList1"
AppendDataBoundItems="true"
>
<asp:ListItem
Enabled="True"
Selected="True"
Text="All"
Value="0"
/>
</asp:DropDownList>
现在,所有数据绑定项都会自动附加,并且不会删除第一项。
答案 2 :(得分:0)
以下为我工作!
向数据源添加新行
Dim dr As DataRow = ds.Tables("cusPracticeLocation").NewRow
'Add some data to it
dr(0) = 0
dr(1) = "All"
ds.Tables("cusPracticeLocation").Rows.InsertAt(dr, 0)