RG-3
RG-3

Reputation: 6188

Dropdown List using LinqDataSource Formatting Issue

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?

Upvotes: 2

Views: 575

Answers (2)

Vinay B R
Vinay B R

Reputation: 8421

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

Upvotes: 1

Adi
Adi

Reputation: 5223

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

<asp:DropDownList ID="ddlEntities" runat="server"
   DataSourceID="LinqDataSource3" DataTextField="Name">
</asp:DropDownList>

Upvotes: 0

Related Questions