AshOoO
AshOoO

Reputation: 1148

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

Upvotes: 0

Views: 978

Answers (1)

Gavin Ward
Gavin Ward

Reputation: 1022

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.

i.e.

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")) %>

Upvotes: 1

Related Questions