我希望将从SqlDataSource的Select命令返回的"DisplayName“列值传递给一个自定义函数,然后将返回值分配给DropDownList的"DataTextField”属性。
我知道,我可以使用"CustomExpressionBuilder“来做到这一点,我已经尝试过了,但如果我使用以下命令:
DataTextField="<%$ MyCustomExpressionBuilder:DisplayName %>" 在被覆盖的"GetCodeExpression“方法中,我没有收到DisplayName字段的值,而是收到了文字值"DisplayName”。
我该怎么做呢?请帮帮我。
<asp:DropDownList ID="drpCourseType" runat="server" DataSourceID="sqldsCourses"
DataTextField="DisplayName" DataValueField="Type" CssClass="FilterDropdown">
</asp:DropDownList>
<asp:SqlDataSource runat="server" ID="sqldsCourses"
SelectCommand="SELECT Type,DisplayName FROM CourseTypes ORDER BY OrderID"
ConnectionString="<%$ ConnectionStrings:connectionString %>"></asp:SqlDataSource>发布于 2010-06-09 23:34:13
我不认为您能够以这种方式实现它;我认为您将不得不通过编程将元素添加到下拉列表中。
可能是错误的,但设计器绑定方法在这方面的功能是有限的;您不能基于数据值更改数据文本字段。
https://stackoverflow.com/questions/3004585
复制相似问题