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 6053767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:04:40+00:00 2026-05-23T08:04:40+00:00

I am working on asp.net mvc3. I have designed database in SQL Server. And

  • 0

I am working on asp.net mvc3. I have designed database in SQL Server. And I access database using ado.net, I am designing a “CREATE” page.

This is my view.cshtml

@model CalcoWOMS.Models.ProductFormulation

@{
    ViewBag.Title = "doProductFormulation";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>ProductFormulation</legend>

      <div>  


          @Html.EditorFor(model => model.ProductID) <!-- i want to insert fix value (100) in this ProductID field in ProductFormulation Table -->
            @Html.ValidationMessageFor(model => model.ProductID)
    </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.RawMaterialID)
        </div>
        <div class="editor-field">
            @Html.DropDownList("RawMaterialID","SELECT")
            @Html.ValidationMessageFor(model => model.RawMaterialID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Code)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Code)
            @Html.ValidationMessageFor(model => model.Code)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MinimumBatchSize)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.MinimumBatchSize)
            @Html.ValidationMessageFor(model => model.MinimumBatchSize)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Quantity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Quantity)
            @Html.ValidationMessageFor(model => model.Quantity)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "ProductFormulationIndex")
</div>

I want to insert fixed value (100) in this ProductID field in ProductFormulation table and don’t want to create editable box. What should I
do for 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-05-23T08:04:40+00:00Added an answer on May 23, 2026 at 8:04 am

    Perhaps I don’t understand the question (I’m more of a backend developer), but it seems like the simple solution is remove these two lines:

    <div>
          @Html.EditorFor(model => model.ProductID) 
          @Html.ValidationMessageFor(model => model.ProductID)
    </div>
    

    Then update the Model in your controller’s Create, [post] method to update the ProductID to 100, prior to writing it out to the repository. Of course, how you’d do that depends on your controller structure, which you haven’t posted.

    As I understand it, the alternative would be to have a hidden field on the page and create the Model with a ProductID of 100 in the initial Create call but if you’re always going to hard code the product id (which to be honest seems questionable) to 100, then this seems pointless…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a web application project using ASP.NET MVC3 and database in SQL
I have a webpage I am working on using asp.net mvc3. I am deploying
I am working on asp.net mvc3 application and have many records coming from database.
I working on asp.net mvc3 project. I am using autofac for DI. I have
We have some files stored in sql database. On an ASP.NET MVC3 form, we
I have a simple ASP.NET MVC 3 application. I have the database I designed
I am working on ASP.NET MVC3. I have a partial view RestaurantAdminNavigation.ascx which i
I have working application in asp.net MVC3. Today when I was working on it
Here is my dilemma, I am working on some SaaS using ASP.net MVC3 and
I am currently working on an ASP.NET MVC3 website. I have a simple authentication

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.