0

I am trying to convert online from VB.NET to C# in ASP.NET

this is the line

<asp:Label ID="PriceLabel" runat="server" Visible="false" Text='<%# IIf(DataBinder.Eval(Container.DataItem, "NewPrice") = 0, Eval("Price"),Eval("NewPrice"))%>'></asp:Label>

But I don't know how to use the IIF in c#!!

Did anyone use it before?

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
HAJJAJ
  • 3,667
  • 14
  • 42
  • 70

2 Answers2

2
<%# (DataBinder.Eval(Container.DataItem, "NewPrice") == 0) ? Eval("Price") : Eval("NewPrice") %>
Curtis
  • 101,612
  • 66
  • 270
  • 352
1
<asp:Label 
    ID="PriceLabel" 
    runat="server" 
    Visible="false" 
    Text='<%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "NewPrice")) == 0 ? Eval("Price") : Eval("NewPrice"))%>' 
/>
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928