I have a table with different numbers and I would like to put spaces every 3 numbers.
For example : 1500 = 1 500 or 10000 = 10 000
My code :
<div class="table-responsive" style="padding-top:30px;">
<table class="table table-bordered">
<thead>
<tr>
@foreach (string row in ViewBag.ListEntete)
{
<th>@row</th>
}
</tr>
</thead>
<tbody>
@{
List<List<string>> listHisto = ViewBag.ListHisto;
bool isClassSuccess = true;
string classLigne;
foreach (List<string> item in listHisto)
{
if (isClassSuccess)
{
classLigne = "class=warning";//jaune clair
isClassSuccess = false;
}
else
{
classLigne = "class=success";//vert clair
isClassSuccess = true;
}
@:<tr @classLigne>
foreach (string row in item)
{
<td>@row</td>
}
@:</tr>
}
@:<tr class="active">
<td>CUMUL</td>
foreach (string row in ViewBag.ListCumul)
{
<td>@row</td>
}
@:</tr>
}
</tbody>
</table>
My numbers are in a list.
dac = new SqlDataAdapter(sql, cn);
dsc = new DataSet();
dac.Fill(dsc, "histo");
List<List<string>> listHisto = new List<List<string>>();
foreach (DataRow row in dsc.Tables["histo"].Rows)
{
List<string> listRow = new List<string>();
listRow.Add(row["ENTITE"].ToString());
listRow.Add(row["M01"].ToString());
listRow.Add(row["M02"].ToString());
listRow.Add(row["M03"].ToString());
listRow.Add(row["M04"].ToString());
listRow.Add(row["M05"].ToString());
listRow.Add(row["M06"].ToString());
listRow.Add(row["M07"].ToString());
listRow.Add(row["M08"].ToString());
listRow.Add(row["M09"].ToString());
listRow.Add(row["M10"].ToString());
listRow.Add(row["M11"].ToString());
listRow.Add(row["M12"].ToString());
listRow.Add(row["TT"].ToString());
listHisto.Add(listRow);
}
list.Add("histo", listHisto);
I tried to change row["M09"].ToString()
by row["M09"].ToString("n", nfi)
but I have this errors :
Thanks in advance for your help
>` instead of `List
– Gian Paolo Dec 12 '16 at 10:08>`): then it's quite easy to format them the way you prefer.