2

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" 
    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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
RG-3
  • 6,088
  • 19
  • 69
  • 125

2 Answers2

1

You need to use the DataTextField and DataValueField properties on the dropdown list

Vinay B R
  • 8,089
  • 2
  • 30
  • 45
0

I think you need to specify the DataTextField. Something like this:

<asp:DropDownList ID="ddlEntities" runat="server"
   DataSourceID="LinqDataSource3" DataTextField="Name">
</asp:DropDownList>
Adi
  • 5,113
  • 6
  • 46
  • 59