1
我正在创建一个网站,其中有1个dropdownlist绑定到Northwind数据库Customers表。此下拉列表将列出表格中的所有国家/地区。我试图将“日本”(不在列表中)添加到此下拉列表中。它已被添加,但始终显示在顶部(或默认值)。我的问题是:是否可以添加日本,而不是让它出现在顶部,所以它会按照字母顺序?为数据绑定添加价值DropDownlist(asp.net)
这是我的代码:
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Country"
DataValueField="Country"><asp:ListItem Text ="Japan" />
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2 %>"
SelectCommand="SELECT Country FROM Customers GROUP BY Country ORDER BY Country">
</asp:SqlDataSource>
太感谢你了,这正是我一直在寻找 – 2012-02-23 02:03:42
请接受,如果该解决方案是正确的,你很高兴.. – 2012-02-23 02:06:42