Nesting <asp:Menu> inside Repeater Control

P

philhey

Hi,

I want to use a <asp:Menu> inside a repeater control, and dynamiclly
set the properties of the menu using the repeaters datasource like the
sample below.

However I get the error "Code blocks are not supported in this context"

I can see why this doesn't work, but can any one suggest a work around
for it.

Thanks Phil


<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="ObjectDataSource1">
<HeaderTemplate>
<table>
<tr>
<th scope="col">Proj. No</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Menu ID="Menu" runat="server">
<StaticSelectedStyle CssClass="menuSelectedItem" />
<DynamicMenuStyle CssClass="menuPopup" />
<DynamicMenuItemStyle CssClass="menuPopupItem" />
<DynamicHoverStyle CssClass="menuPopupItem" />
<StaticHoverStyle CssClass="menuItemHover" />
<Items>
<asp:MenuItem Text="<%
DataBinder.Eval(Container.DataItem, "jobID") %>" />
</Items>
</asp:Menu>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
 
P

philhey

I've managed to workout a solution for this an I thought I might as
well share in case some one found my topic:

I used a GridView instead of a repeater (Which i wanted to use anyway
but didnt think it would do the job) and added my <Asp:Menu> on the
RowdataBound event

Private Sub DG_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound

Dim ami As New MenuItem
ami.Text = jobName
ami.NavigateUrl = "job.aspx?jobID=" & jobID
Dim amiDocuments As New MenuItem
amiDocuments.Text = "Documents"
amiDocuments.NavigateUrl = "documents.aspx?jobID=" & jobID
ami.ChildItems.Add(amiDocuments)
aMenu.Items.Add(ami)
e.Row.Cells(2).Controls.Add(aMenu)
End Sub
 

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

Similar Threads

repeater 0
asp:Menu bug? 3
ASP:Menu 0
ASP:Menu 0
How to access Labels inside Repeater 2
Can I Use RequiredFieldValidator inside a repeater ? 3
Nested repeater controls 0
asp:menu cssclass? 2

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top