Ich mache MVC ASP.NET App und ich bin Neuling dazu kann mir bitte jemand sagen, wie man Wert von Checkbox Bool in String konvertieren und wo dies in Teilklasse oder in Controller zu tun? Checkbox mark is shown in my tableWie konvertiert man den Wert von Checkbox Bool in String kann mir jemand ASP.NET MVC helfen?
// GET: InspekcijskeKontrole/Create
public ActionResult Create()
{
ViewBag.InspekcijskoTijeloId = new SelectList(db.InspekcijskoTijeloes, "InspekcijskoTijeloId", "NazivInspekcijskogTijela");
ViewBag.ProizvodId = new SelectList(db.Proizvods, "ProizvodId", "NazivProizvoda");
return View();
}
// POST: InspekcijskeKontrole/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "InspekcijskoTijeloId,ProizvodId,DatumInspekcijskeKontrole,Rezultat,ProizvodSiguran,InspekcijskaKontrolaId")] InspekcijskaKontrola inspekcijskaKontrola)
{
if (ModelState.IsValid)
{
db.InspekcijskaKontrolas.Add(inspekcijskaKontrola);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.InspekcijskoTijeloId = new SelectList(db.InspekcijskoTijeloes, "InspekcijskoTijeloId", "NazivInspekcijskogTijela", inspekcijskaKontrola.InspekcijskoTijeloId);
ViewBag.ProizvodId = new SelectList(db.Proizvods, "ProizvodId", "NazivProizvoda", inspekcijskaKontrola.ProizvodId);
return View(inspekcijskaKontrola);
}
möchten Sie Boolean in Zeichenfolge konvertieren? Warum rufen Sie nicht 'ToString()' Methode für Ihren booleschen Wert auf? – Shyju
Ich möchte etwas schreiben wie das Produkt ist sicher, wenn die Checkbox wahr ist – Jhony2
Entschuldigung! Was bedeutet das ? Warum denken Sie, dass das Aufrufen von 'ToString()' auf einem booleschen Wert Ihr Produkt unsicher macht? – Shyju