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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:35:38+00:00 2026-05-22T12:35:38+00:00

I have following in database (and I use them as models): Category { long

  • 0

I have following in database (and I use them as models):

Category
{
long id;
string name;
long subcategoryId;
}

Subcategory
{
long id;
string subName;
//other data
}

I get data from db with Entity SQL like:

public static Category GetCategory(long catId)
        {
            Category cat;
            using (Entities db = new Entities())
            {
                cat = (from c in db.Categories
                       where c.id == catId
                       select c).SingleOrDefault();

                cat.SubcategoryReference.Load();
            }
            return cat;
        }

Now, I have some partial view:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Test.Database.Subcategory>>" %>
<%--Some code--%>
<%:Html.ActionLink("Move to new category", "editcategory", "category",
                                             new { model = new Category { Subcategory = item } }, null)%>

Plan is to navigate with this action link to CategoryController and action

public ActionResult EditCategory(Category model)
        {
            //some code
            return View(model);
        }

where I can edit some info about this category which would contain chosen subcategory. Problem is that I keep getting model=null as parameter in this EditCategory Action. What am I doing wrong? Any advice is welcome.

  • 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-22T12:35:39+00:00Added an answer on May 22, 2026 at 12:35 pm

    You cannot pass complex objects using GET as action links. If you wanted to do this you will need to send all properties, one by one and leave the default model binder cope with it but this could be very tedious:

    <%: Html.ActionLink(
        "Move to new category", 
        "editcategory", 
        "category",
        new { 
            prop1 = item.Prop1,
            prop2 = item.Prop2,
            ...
        }, 
        null
    )%>
    

    I would recommend you the standard way to achieve which consists in passing the category id that you are willing to edit:

    <%: Html.ActionLink(
        "Move to new category", 
        "editcategory", 
        "category",
        new { id = item.Id }, 
        null
    ) %>
    

    and inside the controller action fetch the corresponding model from the repository:

    public ActionResult EditCategory(int id)
    {
        Category model = ... fetch category from id
        //some code
        return View(model);
    }
    

    Then the corresponding view will contain a form with input fields for all the different category properties and it is the POST action which you will submit this form to that can take a Category model as action parameter:

    [HttpPost]
    public ActionResult EditCategory(Category category)
    {
        if (!ModelState.IsValid) 
        {
            return View(model);
        }
        // some code to update the category
        return RedirectToAction("Success");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following data to save in database using php my data is :
I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2> .
Let just say I have the following data models: public class Account { public
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
I have the following criteria Database should be protected with a username and password.
I have the following tables in my database that have a many-to-many relationship, which
I have the following table relationship in my database: Parent / \ Child1 Child2
I have the following entry in my database: t.time :my_time_stamp In my controller I
I have the following problem in a Database using Access 2007 as front end

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.