Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting string to int (2)
    primarykey
    data
    text
    <p>I am using the following action to save Nav Bar Items edited from with admin of a content management system:</p> <pre><code> [HttpPost] public ActionResult aSaveNavs() { aLoggedIn(); NavItemsDataContext navDB = new NavItemsDataContext(); Nav n = navDB.Navs.Select(row =&gt; row.ID == Convert.ToInt32(Request.Form["ID"])); n.NavName = Request.Form["NavName"]; n.NavURL = Request.Form["NavURL"]; n.NavEnabled = (Request.Form["NavEnabled"] == "true" ? true : false); navDB.SubmitChanges(); return Redirect("/Admin/aHome"); } </code></pre> <p>I am using the following view:</p> <pre><code>@{ List&lt;Nav&gt; navList = HtmlHelpers.GetNavList(); } @foreach (Nav item in navList) { &lt;tr&gt; &lt;td style="width: 150px; text-align: center;"&gt; @item.NavName &lt;/td&gt; &lt;td style="width: 150px; text-align: center;"&gt; &lt;input id="NavName" name="NavName" type="text" value="@item.NavName" /&gt; &lt;/td&gt; &lt;td style="width: 150px; text-align: center;"&gt; &lt;input id="NavURL" name="NavURL" type="text" value="@item.NavURL" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input id="ID" name="ID" type="text" readonly="readonly" value="@item.ID" /&gt; &lt;/td&gt; &lt;/tr&gt; } </code></pre> <p>Obviously the view has a few other bits in but this is the section in question.</p> <p>When I try and save my changes, I get "System.FormatException: Input string was not in a correct format." and the following line is highlighted:</p> <pre><code>Nav n = navDB.Navs.FirstOrDefault(row =&gt; row.ID == Convert.ToInt32(Request.Form["ID"])); </code></pre> <p>Thanks in advance for any help with this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload