-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to use DataBind with an object graph (nested object
hierarchy). I'm getting the top-level object, but not the children. What
am I doing wrong?

The object graph is like this:

Exam has_many Page
Page has_many Question
Question has_many Choice
Question has_many Answer

My controller action looks like this:

public void SubmitStudentExam( [DataBind("Page")] Page[] pages )
{
.....
}

My page code (inline aspx) is this:

<%@ Import Namespace="Offline.WSDL.Services" %>
<%@ Import Namespace="Castle.MonoRail.Framework.Helpers" %>
<%@ Import Namespace="Castle.MonoRail.Framework" %>
<%@ Implements Interface="Castle.MonoRail.Framework.IControllerAware" %>
<script runat="server">

        private Controller _controller;
        private HtmlHelper h;
        private StudentExam studentExam;
        //private int idForBackLink;
        private Question q;
        //private int pageCounter;

        public void SetController( Controller controller )
        {
                _controller = controller;
                h = _controller.Helpers["HtmlHelper"] as HtmlHelper;
                studentExam = _controller.PropertyBag["studentExam"] as 
StudentExam;
                //idForBackLink = (int)_controller.PropertyBag["thisID"];
                //pageCounter = 0;
        }
</script>
<%= h.Form( "SubmitStudentExam." + _controller.Context.UrlInfo.Extension
) %>
<%= h.InputHidden( "[EMAIL PROTECTED]", studentExam.Pages.Length ) %>
<table>
        <% for( int pageCount=0; pageCount < studentExam.Pages.Length;
pageCount++ ) { %>
        <% Offline.WSDL.Services.Page page = studentExam.Pages[pageCount]; %>
        <tr>
                <td>
                        <table>
                                <tr>
                                        <th colspan="2">
                                                <strong>PAGE <%= pageCount + 1 
%></strong>
                                                <%= h.InputHidden( 
string.Format( "Page[{0}].ID", pageCount ),
page.ID ) %>
                                        </th>
                                </tr>
                                <tr>
                                        <td>ID</td>
                                        <td><%= page.ID %></td>
                                </tr>
                                <tr>
                                        <td>Title</td>
                                        <td><%= page.Title %></td>
                                </tr>
                                <tr>
                                        <td>Instructions</td>
                                        <td><%= page.Instructions %></td>
                                </tr>
                                <tr>
                                        <td>Questions</td>
                                        <td>
                                                <ul>
                                                <% for( int questionCount=0; 
questionCount <
page.Questions.Length; questionCount++ ) { %>
                                                        <% q = 
page.Questions[questionCount]; %>
                                                        <li>
                                                                <% //h.LinkTo( 
q.Text, "Exam", "ExamQuestion",q.ID ) %>
                                                                <%= 
h.InputHidden( string.Format( "Page[{0}].Questions[{1}].ID",
pageCount, questionCount ), q.ID ) %>
                                                                <%= 
h.InputHidden( string.Format( "[EMAIL PROTECTED]",
pageCount ), page.Questions.Length ) %><br />
                                                                <% switch( 
q.QuestionType ) {
                                                                        case 
ExamQuestionTypes.FillInTheBlank:
                                                                                
break;
                                                                        case 
ExamQuestionTypes.ManyMultipleChoice:
                                                                                
break;
                                                                        case 
ExamQuestionTypes.Matching:
                                                                                
break;
                                                                        case 
ExamQuestionTypes.MultipleChoice:
                                                                                
break;
                                                                        case 
ExamQuestionTypes.TrueFalse: %>
                                                                <%= 
h.InputRadio( string.Format(
"Page[{0}].Questions[{1}].StudentAnswers[0].Text", pageCount,
questionCount ), q.Choices[0].Text ) %> <%= q.Choices[0].Explanation
%><br />
                                                                <%= 
h.InputRadio( string.Format(
"Page[{0}].Questions[{1}].StudentAnswers[0].Text", pageCount,
questionCount ), q.Choices[1].Text ) %> <%= q.Choices[1].Explanation
%><br />
                                                                                
<% break;
                                                                        default:
                                                                                
break;
                                                                } %>
                                                        <% } %>
                                                        </li>
                                                </ul>
                                        </td>
                                </tr>
                        </table>
                </td>
        </tr>
        <% } %>
</table>
<%= h.SubmitButton( "Submit" ) %>
<%= h.EndForm() %>


Thanks in advance!

Cheers,

Kevin

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFJToZ28MvkaQ+4e8RAnwTAJ9zXqJxn9Wvr2p9ELZ9Zm/D0mlU5QCggs05
9d0JFuHN6mcX20EMYVM5PJ0=
=RtlF
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
CastleProject-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/castleproject-users

Reply via email to