简体   繁体   English

从资源值和数据项绑定转发器项

[英]Bind repeater item from resource value and data item

I need to bind a label inside a repeater control using 我需要使用

<%# DataBinder.Eval(... %>

but the Data item is contain the value not the text which should be present 但是“数据”项包含的值不是应显示的文本

So the case like 所以这样的情况

DataBinder.Eval(Container.DataItem, "CarCode")

and the car code will be "Frd1" for example, but it should show "Ford Edge" which stored in a resource file with value "Frd1" So is there any way to retrieve the text value from the resource file direct in same line while binding 例如,汽车代码将是“ Frd1”,但是它应该显示“ Ford Edge”,它存储在资源文件中,值为“ Frd1”。因此,有什么方法可以直接在同一行中从资源文件中检索文本值,而捆绑

I'm not sure what you mean exactly by resource file but you can create a function on that page to look up a car's model from it's code and use that for data binding. 我不确定资源文件到底是什么意思,但是您可以在该页面上创建一个函数,以从代码中查找汽车的模型并将其用于数据绑定。

ie

protected string GetCarModelFromCode(string code)
{
    //Do look up here, say you store it as string carModel

    return carModel;
}

and then in your declarative code do: 然后在您的声明性代码中执行以下操作:

<%# GetCarModelFromCode(Eval(Container.DataItem,"CarCode")) %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM