How can be a Template field label text property set from code behind on page loading?

49 Views Asked by At

I have a Gridview with the following template field:

<asp:TemplateField HeaderText="Media">
<ItemTemplate>
<asp:label ID="lblMedia" runat=server Text='<%# If(Eval("TMO1") is DbNull.Value, "-", GralFunctions.Format(Eval("TMO1")))%>'></asp:label>
<ItemTemplate>
</asp:TemplateField>

"TMO1" field corresponds to a DataBase field and I need to set a different value depending on the field I need to show.

It exists "TMO1" and "TMO2" corresponding a different values and I need to determine what field is to be shown on page loading proccess.

In vb I would write something like:

<asp:label ID="lblMedia" runat=server Text='<%# If(Eval(" & "XXXXXX" & ") is DbNull.Value, "-", GralFunctions.Format(Eval(" & "XXXXXX" & ")))%>'></asp:label>

Do anyone know how can it be done on page loading?

0

There are 0 best solutions below