Matrix question and nested repeaters

A

Allan Ebdrup

Hi,
I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix
question is a question where you have several options that can all be rated
according to several possible ratings (from less to more for example).
I have a question object that has two properties that contain the
collections Options and Ratings.
now I want this kind of layout:
---
Rating1 Rating2 Rating3
Option 1 () () ()
Option 2 () () ()
Option 3 () () ()
---
The ()'s are radiobuttons.
I'm creaing the Matrix question as a Web User Control (.ascx page).
The web user control get's the question set in a property that I've added
called Question.

Now I've created a repeater that has it's datasource set to Options. And in
the header template I want to write the ratings (later I also want to create
the radiobuttons by creating a nested repeater over the ratings in the item
template).
---
<asp:Repeater ID="MatrixRepeater" runat="server">
<HeaderTemplate>
<table>
<tr>
<td>
</td>
<asp:Repeater runat="server" ID="HeaderRepeated"
DataSource="Question.Ratings">
<ItemTemplate>
<td><%# Eval(Container.DataItem, "Text") %>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</HeaderTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
---
My first question is: What do I write where I set the datasource for the
HeaderRepeater, where I've written "Question.Ratings"?
My Web User Control (.ascx) has a property named Question that has a
property called Ratings that I want to use as datasource.

My second question: Is this a good design, using Repeater controls, or is
there a better way to get the output I'm seeking?

Kind Regards,
Allan Ebdrup
 
A

Allan Ebdrup

I found a solution:
---
<asp:Repeater ID="MatrixRepeater" runat="server">
<HeaderTemplate>
<table>
<tr>
<td>
&nbsp;
</td>
<asp:Repeater runat="server" DataSource="<%#
((Controls_Survey_Questions_MatrixQuestion)Container.Parent.Parent).Question.Ratings
%>">
<ItemTemplate>
<td valign="bottom">
<%# Eval("Text")%>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("Text") %>
</td>
<asp:Repeater ID="RatingsRepeater" runat="server"
DataSource="<%#((Controls_Survey_Questions_MatrixQuestion)Container.Parent.Parent).Question.Ratings
%>">
<ItemTemplate>
<td valign="top" align="center">
<cc1:GlobalRadioButton
ID="GlobalRadioButton1" runat="server"
GlobalGroup="true"
GroupName="<%#
((CopenhagenSoftware.UserFeedback.QuestionOption)((RepeaterItem)Container.Parent.Parent).DataItem).Id
%>"
/>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
---

I don't think that all the dotting to Parent.Parent and casting is very
pretty but it works, now all I have to figure out is how to retrieve what
radiobuttons were clicked.

I'm using the GlobalRadioButton control I found here:
http://metabuilders.com/Tools/GlobalRadioButton.aspx
Because of the probles ASP.Net has with having radiobuttons belonging to the
same group inside repeater controls.

Kind Regards,
Allan Ebdrup
 
W

Walter Wang [MSFT]

Hi Allan,

It seems you've found the solution yourself. I'm not sure if you have more
questions or not. Please feel free to reply here to let me know if there's
anything I can help.

Have a nice day and Merry Christmas!


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top