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

  • Home
  • SEARCH
  • 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 8991397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:43:00+00:00 2026-06-15T22:43:00+00:00

controller: public ActionResult Edit(int id) { SetViewData(); var rule = _db.AlertRules.Find(id); ViewData[rule] = rule.Feed.Name

  • 0

controller:

    public ActionResult Edit(int id)
    {
        SetViewData();
        var rule = _db.AlertRules.Find(id);

        ViewData["rule"] = rule.Feed.Name + " - "
            + rule.Template.Name;
        return View(rule);
    }

    //
    // POST: /AlertRule/Edit/5
    [HttpPost]
    public ActionResult Edit(AlertRule alertrule)
    {
        SetViewData();
        alertrule.UpdateDateTime = DateTime.Now;
        if (ModelState.IsValid)
        {
            _db.Entry(alertrule).State = EntityState.Modified;
            _db.SaveChanges();
            return RedirectToAction("Index");
        }
        else
        {
            TempData["error"] = "Cant update rule({0})"
                + alertrule.Id;
        }

        return View(alertrule);
    }

    private void SetViewData()
    {
            var feeds = new SelectList(_db.Feeds.OrderBy(f => f.Name), "Id", "Name");
            var templates = 
                 new SelectList(_db.AlertRuleTemplates.OrderBy(f => f.Name), "Id", "Name");

            ViewData["templates"] = templates;
            ViewData["feeds"] = feeds;
    }

view:

@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
    <legend>Edit</legend>
    @Html.HiddenFor(model => model.Id)

    <div class="editor-label">
        @Html.LabelFor(model => model.FeedId)
    </div>
    <div class="editor-field">
        @Html.DropDownListFor(model => model.FeedId, (SelectList)ViewData["feeds"])
        @Html.ValidationMessageFor(model => model.FeedId)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.TemplateId)
    </div>

    <div class="editor-field">
        @Html.DropDownListFor(model => model.TemplateId, 
              (SelectList)ViewData["templates"])
        @Html.ValidationMessageFor(model => model.TemplateId)
    </div>

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

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

    <div class="editor-label" style="display: none">
        @Html.LabelFor(model => model.UpdateDateTime)
    </div>
    <div class="editor-field" style="display: none">
        @Html.EditorFor(model => model.UpdateDateTime)
        @Html.ValidationMessageFor(model => model.UpdateDateTime)
    </div>

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

form data:

Id:33
FeedId:1
TemplateId:1
Enable:false
Alertrule:00000
UpdateDateTime:12/10/2012 3:02:15 PM
  • 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-15T22:43:01+00:00Added an answer on June 15, 2026 at 10:43 pm

    That’s a common gotcha. There seems to be an Alertrule property in your model which is conflicting with your action argument name. So rename your action argument:

    [HttpPost]
    public ActionResult Edit(AlertRule model)
    

    Or rename the AlertRule property name to avoid the conflict.

    The problem is the following property:

    Alertrule:00000
    

    Since your action argument is called the same way the default model binder is attempting to bind the value 00000 to the alertRule parameter which obviously fails.

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

Sidebar

Related Questions

I have the following controller action: public ActionResult Edit(int id) { var news =
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It
Lets say i have the following controller: // // GET: /Courses/Edit/5 public ActionResult Edit(int
I have a controller that sets TempData before returning a view, public ActionResult Edit(int
I have the following action method in my Tournament controller: public ActionResult Edit(int id)
I have the following code: [HttpGet] public ActionResult Edit(int req) { var viewModel =
Controller First I tried this: [HttpPost] public ActionResult Edit(JournalEntry journalentry) { if (ModelState.IsValid) {
Have Controller: public class MyController : Controller { [HttpGet] public ActionResult MyAction(int iMode, string
Controller to get an image: public class PicturesSmallController : Controller { public ActionResult Details(int
I have an overloaded action in my Controller: public ActionResult AssignList(int id) { ...

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.