ASP.NET MVC: Partial Class: Should Model Become Generic?

I am creating a shared grid for use in ASP.NET MVC applications. I am having problems with a partial view that gets a generic class passed to it.

I have prepared a small sample project that shows what I want to do. Download it here.

In HomeController, I have two controller actions that use my generic grid class to prepare Employee and Department data to be rendered by a reusable partial view /Shared/SimpleTrustGridViewer.ascx.

The problem is that I am currently getting the Employees controller action when I inherit a partial view like this:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TrustGrid<Employee>>" %>

      

Managing Department Controllers will throw the error I'm stuck on.

I hope someone can take a look at the sample project I have prepared and can suggest a simple, straightforward way to make partial submission work for both staff and departments. No database required or whatever, I just use fake repos.

You can copy the fix code here or the link or mail (* myUserNameWithoutSpace * 1985@gmail.com ) the fixed sample project.

Any help is greatly appreciated!

(This is a follow-up to this question as I was unable to get a good answer there. I prepared a sample project that you can now use to demonstrate what needs to be done.)

Edit . Ignore the IColumn and ITrustGrid interfaces, I played around with them a bit trying to fix this problem.

+1


a source to share


1 answer


Extend a method like .getTrustGrid () to get the same type you want.



+1


a source







All Articles