Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:10:43+00:00 2026-06-09T16:10:43+00:00

I am using the following action to save Nav Bar Items edited from with

  • 0

I am using the following action to save Nav Bar Items edited from with admin of a content management system:

    [HttpPost]
    public ActionResult aSaveNavs()
    {
        aLoggedIn();

        NavItemsDataContext navDB = new NavItemsDataContext();
        Nav n = navDB.Navs.Select(row => 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");
    }

I am using the following view:

@{
List<Nav> navList = HtmlHelpers.GetNavList();
}

@foreach (Nav item in navList)
{
    <tr>
        <td style="width: 150px; text-align: center;">
            @item.NavName
        </td>
        <td style="width: 150px; text-align: center;">
            <input id="NavName" name="NavName" type="text" value="@item.NavName" />
        </td>
        <td style="width: 150px; text-align: center;">
            <input id="NavURL" name="NavURL" type="text" value="@item.NavURL" />
        </td>
        <td>
            <input id="ID" name="ID" type="text" readonly="readonly" value="@item.ID" />
        </td>
    </tr>
}

Obviously the view has a few other bits in but this is the section in question.

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:

Nav n = navDB.Navs.FirstOrDefault(row => row.ID == Convert.ToInt32(Request.Form["ID"]));

Thanks in advance for any help with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:10:44+00:00Added an answer on June 9, 2026 at 4:10 pm

    Convert.ToInt32 may still throw an error, for example when it is empty, therefore use this:

    int result=0;
    Int32.TryParse(Request.Form["ID"].ToString(), out result);
    

    and then in your code:

    Nav n = navDB.Navs.FirstOrDefault(row => row.ID == result);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have the following controller action [HttpPost] public ActionResult Save( CustomerModel model )
i was working with navigation bar button items.i was using the following code to
During generic save action of morphia model using CRUD interface I recieve following error:
i am using the following code to send request to the server var url='getDNormalForm.action';
Are there any pros/cons of using the following two alternatives in your action signature:
I have the following action which is called from a screen with a list
I'm getting values from the html using the following method: javascript: var list =
I am using the following code to save/ load my picture OnCreate(){ super.onCreate(); setContentView(...)
I'm trying to pull data from a QR code via zxing using the following
Using following code I try to get updated list of checkbuttons' corresponding text values,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.