开发者

asp.net division followed by formatting

开发者 https://www.devze.com 2023-04-13 00:29 出处:网络
I have the following code: <tr> <td class=\"add_border_bold\" nowrap=\"nowrap\">Schedule Saved (days)</td>

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}")%>
         &nbsp;
   </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}")%>
      &nbsp;
   </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() %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号