2012-11-26 133 views
0

我使用dropdownlist和SQLDataSource添加在下拉列表中。由於只有1個DataTextField可以顯示,所以我如何添加第二個?我想顯示的列表,這裏的HTML代碼的描述和workprocess,ASP.NET如何在下拉列表中顯示2列?

<asp:DropDownList ID="DropDownWorkProcess" runat="server" DataSourceID="SqlDataSource1" DataTextField="Description" DataValueField="WorkProcess"> 
    </asp:DropDownList> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [Description], [WorkProcess] as workprocess FROM [tblWorkProcess]"></asp:SqlDataSource> 

如果不能正常工作,是否有其他更容易簡單的方式從第三方如AJAX工具包?

+0

Telerik的具有良好的組合框,這將給一個整潔dropdown.http:[顯示器的//demos.telerik.com/aspnet-ajax/combobox/examples/overview/defaultcs.aspx – arunlalam

+0

可能重複更多列從DropDownList中的數據庫](http://stackoverflow.com/questions/6315530/display-more-columns-from-the-db-in-the-dropdownlist) –

回答

1

嘗試拼接領域:

SELECT [Description] + ' ' + [WorkProcess] as workprocess FROM [tblWorkProcess] 
+0

這不起作用,我得到了錯誤的結果,DataBinding:'System.Data.DataRowView'不包含名爲'WorkProcess'的屬性。 – StudentIT