locked
Clickable Webgrid - Pass value onto Sql for Webgrid on new page RRS feed

  • Question

  • User-1422633144 posted

    Hi - Sorry for the rambling title. 

    Here is what i am trying to do: 

    On the homepage is a webgrid list of trolleys - this is from a Table in the DB with Trolley Name and Trolley ID - only the trolley name is visable. 

    I have made this webgrid so that you can click on an individual trolley and it takes you to a second page and displays the trolley name as the header of the page 

    @{
         Page.Title = "Parts";
        var db = Database.Open("ETS");
        var query = "SELECT Trolleydesc FROM Trolleys WHERE trolleydesc = @0";
        var data = db.QuerySingle(query, UrlData[0]);
    }

     @foreach(var item in data.GetDynamicMemberNames()){
         <H1>@data[item]</h1>

    Now what i would like to do is to have another web-grid appear below this header and for that to show all of the individual parts of the trolley selected. this is held in a separate table. I have the SQL below but i dont know how to change the Where Trolleyid = (The TrolleyID value of the trolley the user selected in the first Webgrid) Is this possible? 

    @{
    var selectQueryString = "SELECT * from parts join parts_trolley on parts_trolley.partdesc = parts.partdesc where parts_trolley.trolleyid = @0 order by parts.type"; 
    var tdata = db.Query(selectQueryString); 
    var grid = new WebGrid(tdata, rowsPerPage:50); 
    }
     

    Thank you for any help you can give. 

    Friday, February 26, 2016 12:46 AM

All replies

  • User379720387 posted

    Why don't you pass the trolley id in the url data?

    In the second page you get the trolley name from a query, and the same for the items coming from parts.

    Friday, February 26, 2016 1:15 AM
  • User-1422633144 posted

    Hi thank you for replying. 

    im very sorry but i dont understand how to do that could you point me in the right direction please 

    Sunday, February 28, 2016 11:24 PM
  • User379720387 posted

    Show the code related to the first page.

    Monday, February 29, 2016 3:52 PM