...">

Binding to a ListViewName element comes from a resource

I have a ListView, in its ItemTemplate I bind a field like:
<%#Eval("FiledName") %>
But the name FeildName belongs to resources, for example:
<asp:Localize Text="<%$ Resources: Resources, productnamefield %>" runat="server" />
Now I need something like this:
<%#Eval(<asp:Localize Text="<%$ Resources: Resources, productnamefield %>" runat="server" />) %>
but it is not correct (has a compilation error)
How do I combine these two?

+3
source share
1 answer

Will there be something in this direction:

protected void yourListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
    if (e.Item.ItemType == ListViewItemType.DataItem)
    {
        DataRowView drv = e.Item.DataItem as DataRowView;

        Label filedName = e.Item.FindControl("FiledNameLabel") as Label;      

        //Get resource value
        string resourceValue = GetGlobalResourceObject("ResourceFile","productnamefield").ToString();  
        filedName.Text = drv[resourceValue].ToString();
    }
}

You will then use the shortcut in your ListView to display the value.

+3
source

All Articles