|
-
Oct 6th, 2006, 02:00 AM
#1
Thread Starter
Lively Member
[2005] Checkbox/radiobuttonlist next to childs in master/child data
Hi,
I've got some master/child data and I want to display a checkbox or radiobutton next to each child, depending on a value the master has.
The checkboxes or radiobuttons should also be grouped for each master record. (each master record would have a list of controls, one control next to each of his children).
I am currently displaying the data (without checkbox/radiobuttons) using a nested repeater, but I'm at a loss on how to manage the checkbox/radiobuttons.
I already tried manually putting either a checkboxlist of radiobutton list in ascx file, but I noticed I couldn't put the list above the repeater and dynamically add a listitem for each row.
Any pointers would be welcome.
-
Oct 6th, 2006, 04:27 PM
#2
Re: [2005] Checkbox/radiobuttonlist next to childs in master/child data
-
Oct 9th, 2006, 01:51 AM
#3
Thread Starter
Lively Member
Re: [2005] Checkbox/radiobuttonlist next to childs in master/child data
Code:
<asp:Repeater ID="question" runat="server" OnItemDataBound="question_ItemDataBound">
<ItemTemplate>
<tr>
<td >
<%# DataBinder.Eval(Container.DataItem, "Description") %></br>
</td>
</tr>
<tr>
<td align="right">
<table border="0">
<asp:Repeater ID="answer" runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "Description") %>
</br>
</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<br />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
(Both question and answer tables have a description field)
VB Code:
protected void question_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
{
Repeater Answer = (Repeater)item.FindControl("answer");
DataRowView drv = (DataRowView)item.DataItem;
Answer.DataSource = drv.CreateChildView("Question_Answer");
Answer.DataBind();
}
}
-
Oct 10th, 2006, 09:20 AM
#4
Re: [2005] Checkbox/radiobuttonlist next to childs in master/child data
So shouldn't you just place the master radiobuttons like here:
Code:
<asp:Repeater ID="question" runat="server" OnItemDataBound="question_ItemDataBound">
<ItemTemplate>
<tr>
<td >
<%# DataBinder.Eval(Container.DataItem, "Description") %></br>
<asp:Radiobutton............................ />
</td>
</tr>
<tr>
<td align="right">
<table border="0">
<asp:Repeater ID="answer" runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "Description") %>
</br>
</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<br />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
-
Oct 11th, 2006, 04:37 AM
#5
Thread Starter
Lively Member
Re: [2005] Checkbox/radiobuttonlist next to childs in master/child data
That would show 1 radiobutton for each question. I need one for each answer in each question, grouped by question.
I found out I could manually assign them a group, for instance the questionID. However, that created a problem since ASP renames all the controls when generating the html so they 'wouldn't' end up in the same group after all.
A workaround would be to use a custom radiobutton control that overrides some functionality regarding the name change.
-
Oct 12th, 2006, 10:07 AM
#6
Re: [2005] Checkbox/radiobuttonlist next to childs in master/child data
Ah, now I see what you mean. Yes, ASP.NET does rename these controls and you do end up with independent radio buttons.
How about using a RadioButtonList which, in the ItemDataBound event, you bind to a dataset containing specific answers?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|