Data manipulation in Dropdownlist using DataSource

I have this DropDowList which is using DataSource to display all the items. Which is using this query:

Select distinct [Word] from [Book] order by [Word]

Let's assume that the the query display this following words.

  1. Apple
  2. Orange
  3. Mango
  4. Banana
  5. Pineapple

Now my problem is I want to convert all the Data displaying in the RadiobuttonList to a specific text that I want. For Example , the word Banana to its Spanish word Platano.

Below is the DropDown:

<asp:DropDownList ID="FruitDD" runat="server" DataSourceID="FruitSource" DataTextField="Value" DataValueField="Code" AppendDataBoundItems="True"> <asp:ListItem>- Select Fruit</asp:ListItem>

Here is the code I am using to convert.

FruitDD.Items[1].Text = "[string that I want]";

Which is causing error:

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Is there an effective way that I can convert this using the DataSource?

1 answer

  • answered 2018-02-13 01:38 Ping

    I already have an answer.

    FruitDD.Items[number].Text = "[string]";