ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,288 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
This is my code
<asp:TemplateField HeaderText="FEB">
<FooterTemplate>
<asp:Label ID="FB2" runat="server" Font-Size="16px" ForeColor="red"></asp:Label><br />
<asp:Label ID="FB22" runat="server" Font-Size="16px" ForeColor="teal"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="B2" runat="server" ForeColor="Red" Text='<%#(String.IsNullOrEmpty(Eval("[February QTY]").ToString()) ? "" : Eval("[February QTY]"))%>'
></asp:Label><br />
<asp:Label ID="B22" runat="server" Font-Size="20px" ForeColor="Black" Text='<%# String.IsNullOrEmpty(Eval("[February VALUE]").ToString()) ? "" : (String.Format(System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN"), "{0:#,#}" , decimal.Parse(Eval("[February VALUE]").ToString())))%>'>
</asp:Label>
<br />
<asp:Label ID="B222" ForeColor="Blue" Font-Size="22px" runat="server" Text='<%# ((Eval("February VALUE")!= DBNull.Value ? Convert.ToDouble(Eval("February VALUE")) : 0) / (Eval("[February QTY]")!= DBNull.Value ? Convert.ToDouble(Eval("[February QTY]")) : 0)).ToString("N2") %>'></asp:Label>
</ItemTemplate>
<FooterStyle Font-Size="26px" ForeColor="Teal" HorizontalAlign="Right" />
<HeaderStyle ForeColor="Black" BackColor="#FCF3CF" Font-Size="20px" />
<ItemStyle ForeColor="Teal" HorizontalAlign="Right" Width="100px" />
<ControlStyle Width="100px" />
</asp:TemplateField>
It shows on load Label B222 NaN how to make this NaN to empty
Thanking You
Hi @RAVI,
When 0/0, value = NaN. So you can use the Double.IsNaN(Double) method to judge.
<asp:Label ID="B222" ForeColor="Blue" Font-Size="22px" runat="server" Text='<%# Double.IsNaN((Eval("[February VALUE]")!= DBNull.Value ? Convert.ToDouble(Eval("[February VALUE]")) : 0) / (Eval("[February QTY]")!= DBNull.Value ? Convert.ToDouble(Eval("[February QTY]")) : 0)) ? " " : ((Eval("February VALUE")!= DBNull.Value ? Convert.ToDouble(Eval("February VALUE")) : 0) / (Eval("[February QTY]")!= DBNull.Value ? Convert.ToDouble(Eval("[February QTY]")) : 0)).ToString("N2") %>'></asp:Label>
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.