-1

I have an Obout Grid created, and in a column I want to evaluate that if it is "EN" it puts "Enfermedad", if it is "RE" it puts "Reglamentaria" and if it is "ES" it puts "Estudio"

This is where is done: <%# (Container.Value == "S" ? "Si" : "No")%>

And the full code is this:

<cc1:Grid ID="GridPendientes" runat="server" AllowPageSizeSelection="False"  AllowSorting="False" AutoGenerateColumns="False" FolderStyle="styles/style_8" Language="es"  Width="600" AllowAddingRecords="False"  AllowMultiRecordSelection="false">         
        <ScrollingSettings ScrollHeight="150" />
                        <Columns>
                            <cc1:Column ID="ClmCodFeriado"  DataField="codLicencia" HeaderText="Codigo" Visible="false" Index="0" />
                            <cc1:Column ID="ClmFechaDesde" Width="108" HeaderText="Fecha Desde" DataFormatString="{0:dd/MM/yyyy}" DataField="fechaDesdeLicencia" Index="1" Visible="true" Wrap="True" />
                            <cc1:Column ID="ClmFechaHasta" Width="108" HeaderText="Fecha Hasta" DataFormatString="{0:dd/MM/yyyy}" DataField="fechaHastaLicencia" Index="2" Visible="true" Wrap="True" />
                            <cc1:Column ID="ClmNroDias" Width="90" DataField="cantDiasLicencia" HeaderText="Cant. Días" Visible="true" Index="3" ></cc1:Column>
                            <cc1:Column ID="ClmTipoLic" Width="128" DataField="codTipoLicencia" HeaderText="Tipo" Visible="true" Index="4" >
                                <TemplateSettings TemplateId="TemplateTipoLic" />
                            </cc1:Column>
                            <cc1:Column ID="ClmDescrip" Width="280" DataField="descripLicencia" HeaderText="Descripción" Visible="true" Index="5" ></cc1:Column>
                        </Columns>  
                        <Templates>
                             <cc1:GridTemplate runat="server" ID="TemplateTipoLic">
                                <Template>
                                    <%# (Container.Value == "S" ? "Si" : "No")%>

                                </Template>
                            </cc1:GridTemplate>
                        </Templates> 
                    </cc1:Grid>

1 Answers1

0

I think the best way to to this is mapping the possible values within the desired labels. You can even add more labels and expected values easily.

var labeler = {
    labels: {EN: 'Enfermedad', RE: 'Reglamentaria', ES: 'Estudio'},
    label: function(value) {
        return this.labels[value] ? this.labels[value] : 'Default Label';
    }
};

labeler.label(Container.Value);
Leo Cavalcante
  • 2,327
  • 2
  • 22
  • 30
  • Thanks for the reply but I can't make this work... should I put that code between < &>? Like this: <%# var labeler = { labels: {EN: 'Enfermedad', RE: 'Reglamentaria', ES: 'Estudio'}, label: function(value) { return this.labels[value] ? this.labels[value] : 'Default Label'; } }; labeler.label(Container.Value); %> – Sabrina Lanzotti Feb 22 '15 at 03:09
  • Not sure if you can put JavaScript inside <%# %> tags. Arent they for C#? – Leo Cavalcante Feb 22 '15 at 03:15
  • If I put <%# (Container.Value == "S" ? "Si" : "No")%> it works, but only for two options, lets say I want to evaluate that appart from being an "S" I want to check if its a "T", how would I do that? Right now as it is it only allows to values, Si and No. (Sorry for my english, my native language is Spanish) – Sabrina Lanzotti Feb 22 '15 at 03:18
  • Ok, try this: `<%# (Container.Value == "S" ? "Si" : (Container.Value == "T" ? "Te" : "No")) %>` (Dont worry, my native is Portuguese ;]) – Leo Cavalcante Feb 22 '15 at 03:45