从资源到ListItem的Asp.Net绑定字符串

从资源到ListItem的Asp.Net绑定字符串

问题描述:

我有以下代码。从资源到ListItem的Asp.Net绑定字符串

<asp:DropDownList ID="CurrencyList" AutoPostBack="true" runat="server" OnSelectedIndexChanged="CurrencyList_SelectedIndexChanged"> 
        <asp:ListItem Text="<%$ GetGlobalResourceObject("GlobalResourceBms", "RentPage2FilterByLabel")%>" Value="-1"></asp:ListItem> 
       </asp:DropDownList> 

此代码抛出

分析器错误信息:像文字表现形式 '<%$ GetGlobalResourceObject( “GlobalResourceBms”, “RentPage2FilterByLabel”)%>' 是不允许的。使用“/>代替。

如何这个东西Asp.NET,我需要从资源获取字符串,并把它作为下拉列表的项目

尝试使用

<%# GetGlobalResourceObject("GlobalResourceBms","RentPage2FilterByLabel") %> 

编辑

您将需要以不同的方式添加的项目。

使用rowdatabound方法填充您的ddl。看:

public void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) { 
     DropDownList ddl = (DropDownList)e.Row.FindControl("CurrencyList"); 
     //items. 

    } 
} 
+0

文字内容。( '的 StringBuilder 2013-04-23 12:04:25

+0

感谢的人之内,但我也有点震惊的是ASP .NET在标记中不支持这一点。 – StringBuilder 2013-04-23 12:15:27