Controller:
[HttpPost]
public ActionResult Listar_Json()
{
var id = 5;
var search = Request["search[value]"]; //Aqui pega valor digitado no input, digamos que ele digitou 100.000,01
var query = database.Posts.Join(database.Post_Metas,
post => post.ID,
meta => meta.Post_ID,
(post, meta) => new
{
valor1 = post.Money1, //100000,01
valor2 = meta.Money2 //100000,02
})
.Where(x => x.Post.ID == id)
.ToList();
foreach (var item in query )
{
item.valor1 = item.valor1 ???? //100.000,01
}
query = query
.Where(x => (x.Money1.ToString() ?? "").Contains(search)
.ToList();
return Json(new { data = query }, JsonRequestBehavior.AllowGet);
}
View:
<table id="data_grid" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Valor1</th>
<th>Valor2</th>
</tr>
</thead>
</table>
I want to return value 100000,01 for 100,000,01 . For this, I need to use a foreach
to modify. I can not change valor1
, because it says it can not be assigned, it's read-only.
How can I change the value?