0

我使用带有 SQLDataSource 的下拉列表来添加下拉列表。由于只有 1 个 DataTextField 可以显示,我该如何添加第二个呢?我想在列表中显示描述和工作流程,这里是 HTML 代码,

<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 Toolkit?

4

2 回答 2

1

You can't use a dropdown list to achieve this sort of thing since DropDown lists are rendered on the browser as select elements.

You need to use a custom control. People typically use unordered lists (ul) and list items (li) to achieve the behaviour you want.

Telerik controls use that approach - ul and li. See here: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multicolumncombo/defaultcs.aspx

于 2012-11-26T16:51:58.663 回答
1

尝试连接字段:

SELECT [Description] + ' ' + [WorkProcess] as workprocess FROM [tblWorkProcess]
于 2012-11-26T16:48:38.013 回答