Regardign implementing Custom ExpressionBuilder.

Posted by Puneet Dudeja on Stack Overflow See other posts from Stack Overflow or by Puneet Dudeja
Published on 2010-06-09T09:32:38Z Indexed on 2010/06/09 9:32 UTC
Read the original article Hit count: 243

Filed under:

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>

© Stack Overflow or respective owner

Related posts about ASP.NET