2

I'm using Razor View and i have list . I'm sending this list controller to view and filling inside "div" but when i fill this div's i want to format some numbers in my list?

Do you have any idea?

Here my view code

@{
var statuslist = ViewBag.List;
for (int i = 0; i < statuslist.Count; i++)
{
    <div id="count" style="display:none;">@statuslist.Count</div>
    <div id="@statuslist[i].StationCode" class="@statuslist[i].Alert" style="border:1px solid #808080;border-radius:5px;width:250px;height:100px;float:left;margin:5px;" onclick="opendetail(@statuslist[i].StationCode)">
        <span style="font-size:small;font-family:Verdana;color:#808080">@statuslist[i].StationCode - @statuslist[i].StationName</span>
        <div class="dvstatus_@i">@statuslist[i].Status - Last Check : @statuslist[i].LastCheck</div><input id="alertid_@i" type="text" style="display:none;" value="@statuslist[i].Alert"/>
        <div style="margin-left:10px;margin-top:5px;">
            <div>FUEL - @statuslist[i].TotalWet</div> // here i want to format
            <div>DRY  - @statuslist[i].TotalDry</div> // here i want to format
            @if (statuslist[i].Alert == "ONLINE")
            {
                <img src="~/Content/img/ok.png" style="position: relative;bottom: 35px;left: 160px;width:40px;height:40px;"/>
            }
            else if (statuslist[i].Alert == "WARNING")
            {
                <img src="~/Content/img/alert.png" style="position: relative;bottom: 35px;left: 160px;width:40px;height:40px;"/>
            }
            else
            {
                <img src="~/Content/img/error.png" style="position: relative;bottom: 35px;left: 160px;width:40px;height:40px;"/>
            }

        </div>
    </div>

}
}
saulyasar
  • 797
  • 1
  • 17
  • 45
  • When you say format - as in css format or number format eg `.ToString("d2")` – Pete Mar 27 '18 at 14:11
  • I wrote there number formatting @Pete – saulyasar Mar 27 '18 at 14:12
  • Can you not just add the formatting like the tostring in the above comment? eg `@statuslist[i].TotalDry.ToString("d2")` – Pete Mar 27 '18 at 14:13
  • I'm also doing that but working in my server but not working in customer server probably different regional settings @Pete – saulyasar Mar 27 '18 at 14:14
  • I'm using ToString("N0"); – saulyasar Mar 27 '18 at 14:15
  • have you tried d0 or f0? https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings – Pete Mar 27 '18 at 14:17
  • I tried .ToString("N0") but its working my pc my server but not working in customer i thing because of regional settings @Pete – saulyasar Mar 27 '18 at 14:18
  • Ah right I see, you are wanting to add thousands and millions seperators: https://stackoverflow.com/questions/105770/net-string-format-to-add-commas-in-thousands-place-for-a-number – Pete Mar 27 '18 at 14:20
  • Yes @Pete but i want to use thousand seperator "point" not comma – saulyasar Mar 27 '18 at 14:21
  • https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings - I don't think you can use dots as separators in numbers - how would you know if it is a decimal or a separator? – Pete Mar 27 '18 at 14:22
  • So which one i can use ? @Pete format 123456 to 123.456 – saulyasar Mar 27 '18 at 14:24
  • @Pete because of this i want to use js formatting . I don't neet to know just i want to format number 123456 to 123.456 – saulyasar Mar 27 '18 at 14:36
  • Have you heard of google? type it in and you come up with a lot of answers: https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript end help me if you say that's got commas – Pete Mar 27 '18 at 14:37

0 Answers0