MS MVC issue passing id from main to details
i am fighting this problem almost 2 days and i am desperate. I wanna create the database app. using Linq to sql. First i created the list of powerplants(passed from database) and i want to view detail of each powerplant. But here comes the problem. I propably do something wrong.

Controller:

 

    public ActionResult Databases()
            {
    
    
                var dataContext = new powerPlantModelDataContext();
    
                var powerPlant = from q in dataContext.PowerPlants
                             select q;
    
                ViewData["Powerplant"] = powerPlant.ToList();
    
                return View();
            }
    
            public ActionResult DatabasesDetail(int ID) 
            {
    
                var dataContext = new powerPlantModelDataContext();
    
                var powerPlant = from q in dataContext.PowerPlants
                                 where q.Property.Equals(ID)
                                 select q;
    
                ViewData["Powerplant"] = powerPlant.Single();
    
                return View();
            }

View1:(databases.aspx) - her is the detail link

     <% foreach (RenewalSourcesWeb.Models.PowerPlant pp in (List<RenewalSourcesWeb.Models.PowerPlant>)ViewData["Powerplant"])%>
    <% { %>
    <table>
        <tr>
            <th>
                ID
            </th>
            <th>
                Mesto
            </th>
        </tr>
        <tr>
            <td>
                <%=pp.ID%>
            </td>
            <td>
                <%=pp.Property.BasicProperty.City%>
            </td>
            <td>
                <%= Html.ActionLink("Detail", "DatabasesDetail", new { id = pp.ID_Properties})%>
            </td>
        </tr>
    </table>

View2: databasedetails.aspx (problem)

     <% RenewalSourcesWeb.Models.PowerPlant op = (RenewalSourcesWeb.Models.PowerPlant)ViewData["Powerplant"]; %>
    
         <% foreach (RenewalSourcesWeb.Models.Property q in op.Property)  { %>
    
         <%=op.Property.ConnectProperty.Archivation%>
         <%=op.Property.ContactProperty.ContactName %>
    
        <%} %>


I think there is logical error.I think the problem is that i passing wrong argument to controller or something. If anyone have a clue can you check the action link ,controller and the database detail for mistake.
Thanks, i really appreciate any help.

Juraj
MS MVC issue passing id from main to details
===

i am fighting this problem almost 2 days and i am desperate. I wanna create the database app. using Linq to sql. First i created the list of powerplants(passed from database) and i want to view detail of each powerplant. But here comes the problem. I propably do something wrong.

Controller:

 

    public ActionResult Databases()
            {
    
    
                var dataContext = new powerPlantModelDataContext();
    
                var powerPlant = from q in dataContext.PowerPlants
                             select q;
    
                ViewData["Powerplant"] = powerPlant.ToList();
    
                return View();
            }
    
            public ActionResult DatabasesDetail(int ID) 
            {
    
                var dataContext = new powerPlantModelDataContext();
    
                var powerPlant = from q in dataContext.PowerPlants
                                 where q.Property.Equals(ID)
                                 select q;
    
                ViewData["Powerplant"] = powerPlant.Single();
    
                return View();
            }

View1:(databases.aspx) - her is the detail link

     <% foreach (RenewalSourcesWeb.Models.PowerPlant pp in (List<RenewalSourcesWeb.Models.PowerPlant>)ViewData["Powerplant"])%>
    <% { %>
    <table>
        <tr>
            <th>
                ID
            </th>
            <th>
                Mesto
            </th>
        </tr>
        <tr>
            <td>
                <%=pp.ID%>
            </td>
            <td>
                <%=pp.Property.BasicProperty.City%>
            </td>
            <td>
                <%= Html.ActionLink("Detail", "DatabasesDetail", new { id = pp.ID_Properties})%>
            </td>
        </tr>
    </table>

View2: databasedetails.aspx (problem)

     <% RenewalSourcesWeb.Models.PowerPlant op = (RenewalSourcesWeb.Models.PowerPlant)ViewData["Powerplant"]; %>
    
         <% foreach (RenewalSourcesWeb.Models.Property q in op.Property)  { %>
    
         <%=op.Property.ConnectProperty.Archivation%>
         <%=op.Property.ContactProperty.ContactName %>
    
        <%} %>


I think there is logical error.I think the problem is that i passing wrong argument to controller or something. If anyone have a clue can you check the action link ,controller and the database detail for mistake.
Thanks, i really appreciate any help.

Juraj