Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:DropDownList ID="dropDownList" runat="server" DataSourceID="dataSource" DataValueField="DataValueField" DataTextField="DataTextField" />
- <asp:ObjectDataSource ID="dataSource" runat="server" SelectMethod="SelectForDataSource" TypeName="CategoryDao" />
- public IEnumerable<object> SelectForDataSource()
- {
- return _repository.Search().Select(x => new{
- DataValueField = x.CategoryId,
- DataTextField = x.ToString() // Here is the trick!
- }).Cast<object>();
- }
- <asp:DropDownList ID="ddlType" runat="server" Width="250px" AppendDataBoundItems="true" DataSourceID="dsTypeList" DataTextField="Description" DataValueField="ID">
- <asp:ListItem Value="0">All Categories</asp:ListItem>
- </asp:DropDownList><br />
- <asp:ObjectDataSource ID="dsTypeList" runat="server" DataObjectTypeName="MyType" SelectMethod="GetList" TypeName="MyTypeManager">
- </asp:ObjectDataSource>
Add Comment
Please, Sign In to add comment