¿Los datos no se completaron en la vista parcial en MVC3?

Hi all i have a view Page Named Grids and partial View Named History,i want to show the partial view in my grid page,i have the view in my page but History page doesnt have he data populated in it

   this is my GridsPage

                   var grid = new WebGrid(source: Model, defaultSort: "ResourceName", rowsPerPage: 3);
                     using (Html.BeginForm())
                     { %>  

                         <%: Html.DropDownList("ResourceName", (SelectList)ViewBag.ResourceName, "--Select Project--")%>
                          <%: Html.ValidationMessage("ResourceName")%>  

                           <%: Html.DropDownList("ResourceID", (SelectList)ViewBag.ResourceID, "--Select Project--")%>
                           <%: Html.ValidationMessage("ResourceID")%> 

                           <%: Html.DropDownList("status", (SelectList)ViewBag.status, "--Select Project--")%>                               
                                <form action="Grids.aspx" method="post">
                                 <input type="submit" value="search" />
                        <div id="grid">
                         tableStyle: "listing-border", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",                            
                        grid.Column("ResourceID","Resource ID"),
                        grid.Column("ResourceName","Resource Name"),
                        grid.Column("EmployeEmailID","Employee ID"),
                        header: "",
                        style: "text-align-center",
                        format: (item) => Html.ActionLink("Edit", "Edit", new { ResourceID = item.ResourceID }))
                        <%} %>

               //Rendering the Partial view here
                        <%:Html.Partial("History") %>

this is my Partial view

       <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Gridview_BugTracker.Models.BugTracker_DataHelper>>" %>                 
               <% foreach (var item in Model)
                  { %>                        

this is my controller for Partial view

    public ActionResult History()
        var getbugs = GetBugs();
        return View(getbugs);

its not going to the action method history..can any one correct me where am i doing wrong here

preguntado el 31 de julio de 12 a las 12:07

2 Respuestas

In Your Controller

public ActionResult History()
    var getbugs = GetBugs();        
    return PartialView(getbugs);

and in Your aspx page try this changes

       <%:Html.Action("History") %>

try this changes in your code

Respondido 01 ago 12, 06:08

Html.Partial won't call the controller. You need to specify the model in the call:

<%: Html.Partial("History", GetBugs()) %>

The other option, is RenderAction, which will call the controller, and in fact, the entire runtime (routes, etc):

<%: Html.RenderAction("History", "ControllerName"); %>

Respondido 31 Jul 12, 13:07

@simmon Whitehead for your first solution i am geting an error at GetBugs() it doesn't exist in the context - Recursos Dotnet

GetBugs must be a static method and called via the full type name in a view, e.g: YourProject.YourNamespace.YourClass.GetBugs(). Otherwise, use RenderAction instead. - Simón cabeza blanca

@Simon... am second method used... am getting error ") expected" - Recursos Dotnet

@Simon..am second method used... am getting error ...The best overloaded method match for 'System.Web.HttpUtility.HtmlEncode(string)' has some invalid - Recursos Dotnet

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.