asp.net division followed by formatting
I have the following code:
<tr>
<td class="add_border_bold" nowrap="nowrap">Schedule Saved (days)</td>
<td width="100%" class="add_border">
<%# Eval("schedule_saved_days", "{0:0,0}")%>
</td>
</tr>
<tr>
<td class="add_border_bold" nowrap="nowrap">Scheduled Saved in Months</td>
<td width="100%" class="add_border">
<%# Eval("schedule_saved_days", "{0:0,0}")%>
</td>
</tr>
What the requirement is, is to display the second 'schedule saved' in months, rather than days (for some reason they can't figure it out based on days). previously in coldfusion i had just been dividing the number by 30. i had tried a couple different things like <%# Eval("schedule_saved_days"/30, "{0:0,0.00}")%>
and <%# Eval("schedule_saved_days/30)%&g开发者_高级运维t;
just to get something to work. i'm sure this is a quick fix and my google-fu is failing me. Thanks in advance.
Try something like this:
<%#(Convert.ToDecimal(Eval("schedule_saved_days")) / 30).ToString("0,0")%>
I think something like this is what you are after:
<%# (Eval("schedule_saved_days") / 30).ToString("0,0")%>
You will need to cast it as an integer first and then divide by 30
<%# ((int)Eval("schedule_saved_days", "{0:0,0}")/30).tostring() %>
精彩评论