我有此dropdowList,它使用dataSource显示所有项目。正在使用此查询:
Select distinct [Word] from [Book] order by [Word]
让我们假设查询显示以下单词。
- 苹果
- 橙色
- 芒果
- 香蕉
- 菠萝
现在我的问题是我要将RadioButtonList中显示的所有数据转换为我想要的特定文本。例如,香蕉一词在西班牙语platano中。
下拉列表:
<asp:DropDownList ID="FruitDD" runat="server" DataSourceID="FruitSource" DataTextField="Value" DataValueField="Code" AppendDataBoundItems="True"> <asp:ListItem>- Select Fruit</asp:ListItem>
</asp:DropDownList>
这是我用于转换的代码。
FruitDD.Items[1].Text = "[string that I want]";
引起错误:
索引超出范围。必须是非负的,小于 收藏。参数名称:索引
有没有有效的方法可以使用数据源转换?
我已经有一个答案。
FruitDD.DataBind();
FruitDD.Items[number].Text = "[string]";