I have a dropdownlist which is bound to one of the LDS. Here is the code for that:
<asp:DropDownList ID="ddlEntities" runat="server"
DataSourceID="LinqDataSource3">
</asp:DropDownList>
And the code for LinqDataSource3 is:
<asp:LinqDataSource ID="LinqDataSource3" runat="server"
开发者_如何学C ContextTypeName="Testing.DataAccess.TestingLinq2SqlVs1DataContext"
EntityTypeName="" Select="new (Name)" TableName="Entities" OrderBy="Name">
</asp:LinqDataSource>
Now I am getting the values in this type:
{Name = John}
{Name = Eric}
However, I want just:
John
to be showed. Where should I make changes?
You need to use the DataTextField and DataValueField properties on the dropdown list
I think you need to specify the DataTextField. Something like this:
<asp:DropDownList ID="ddlEntities" runat="server"
DataSourceID="LinqDataSource3" DataTextField="Name">
</asp:DropDownList>
精彩评论