locked
is there a way to implement this with Dynamic Data? RRS feed

  • Question

  • User-1390135866 posted

    (I'm posting this again since I want to implement this with Dynamic Data, moderator moved my previous post to Web Forms forum)

    Hi.

    I'm trying to implement a web form for tables which looks like this:

    Poll (Table)
    PollID (pk)
    Question
    InitialDate
    EndDate

    PollAnswer (Table)
    AnswerID (pk)
    PollID (fk)
    Answer

    Is there a way to accomplish this with scaffolding or is necessary a custom web form? If so, which controls do I need to use to make both tables available to insert/edit in the same web form?

    Thanks for the help!

    Wednesday, July 16, 2008 12:45 AM

All replies

  • User-330204900 posted

    Hi Dom, from what you have posted so far it should work no problem.

    I don't understand what complicated about what you want to do?

    If you want both tables in the same page thats no problem, you can use the wizard or do it manually. Have a look here Part 4 - A DetailsView and a GridView using Validation Groups

    Wednesday, July 16, 2008 3:12 AM
  • User-1390135866 posted

    Thanks Steve, but if I scaffold = true both tables they will be generated as 2 different web forms, and what I want to do is manipulate both tables in a single web form, do I make myself clear now?

    I want to have a insert/edit form with the following fields:

    Question
    PollID (pk) // auto generated
    InitialDate
    EndDate

    and another form below with a grid view and a insert/edit with the fields:

    AnswerID (pk) //auto generated
    PollID (fk) // // the id of the above object
    Answer

    Thanks again!

    Wednesday, July 16, 2008 8:32 AM
  • User-797310475 posted
    I'm away from my work computer right now, but have a look at the ListDetails template for some examples on how this can be done.Although the ListDetails template is meant to show the same element in the details view as the selected one in the list, the general idea is the same. You should be able to modify the DynamicWhereParameter of the details view to point to the FK column, not the PK column and get similar behavior. You will have to do this in a custom page and you might have to declare the TableName properties on controls associated with one or both of the two tables (depending on whether you do this in CustomPages or somewhere completely different).
    Wednesday, July 16, 2008 11:51 AM
  • User-330204900 posted

    Yes I understand all you have to do is either:

    [ScaffoldTable(false)] on table you don't want to appear (if you have scffold=true) or the opposite if you have more tables you want to hide than show [:D]

    Wednesday, July 16, 2008 12:22 PM
  • User-1390135866 posted

     Thanks Stephen but it looks like i'm not being clear.

     I want to know what's the easiest way to implement a one to many relationship using Dynamic Data?
     

    Tuesday, August 19, 2008 11:43 PM
  • User-797310475 posted

     You would probably have to write a custom page for this. Take a look at how the ListDetails template is coded. Your result should be similar, except you'd have to replace the details view with another gridview

    Wednesday, August 20, 2008 12:06 AM