By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,689 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,689 IT Pros & Developers. It's quick & easy.

Matrix question and nested repeaters

P: n/a
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
Dec 20 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)Contain er.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_MatrixQ uestion)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).I d
%>"
/>
</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
Dec 20 '06 #2

P: n/a
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 (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Dec 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.