Reputation: 7667
I want to pass the "DisplayName" column value returned from SqlDataSource's Select command to a custom function and then the return value to be assigned to "DataTextField" property of DropDownList.
I know, I can do this using "CustomExpressionBuilder", I have tried but if I use following:
DataTextField="<%$ MyCustomExpressionBuilder:DisplayName %>"
I do not receive the value of the DisplayName field in the overriden "GetCodeExpression" method, but the literal value "DisplayName".
How can I do this? Please help me.
<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>
Upvotes: 1
Views: 100
Reputation: 50728
I don't think you are going to be able to achieve it that way; I think you are going to have to programmably add the elements to the drop down.
Could be wrong, but the designer binding approach is limited in that respect in what it can do; you can't change the data text field based upon a data value.
Upvotes: 1