need help formating text in gridview
I know how to use the dataformattext field with a boundfield but now i am taking two of my columns and dividing them for a percentage 开发者_StackOverflowso i want {0:P1} also how can i stop divide by 0 errors
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("total2")/Eval("acdcalls")%>'
Visible='<%# Eval("total2")/Eval("acdcalls") %>'></asp:Label>
</ItemTemplate>
You should use a method to do that.
In the method you will check if the code is not dividing by 0 and all the logic you need (like formatting).
<asp:Label ID="Label1" runat="server" Text='<%# Divide(Eval("total2"), Eval("acdcalls")) %>'
Visible='<%# Divide(Eval("total2"), Eval("acdcalls")) %>'></asp:Label>
精彩评论