Problem with nested Repeater and ItemCommand Event

P

Patrik Persson

Hello all

I have got a problem with a nested repeater and the ItemCommand Event.
I am adding handler for the ItemCommand and ItemBound. The ItemBound
works perfect but I cant seem to get the linkbuttons to work with
ItemCommand in the inner repeater. Can someone please help me?

The following code (almost) is my problem!

ASP CODE
--------
<asp:Repeater id="rptArticleGroup" runat="server" Visible="True">
<ItemTemplate>
<TR><td colspan="4">
<u><%#Container.DataItem("ArticleGroupname")%></u>
</td></TR>

<asp:Repeater id="rptArticles" runat="server">

<ItemTemplate>
<tr><td width="140">
<%#Container.DataItem("ArticleName")%>
</td>
<td width="170">
<asp:LinkButton id="lbuChangeArticle" runat="server"
CommandName="Change" CausesValidation="false">[Change
Article]</asp:LinkButton>
</td>
<td width="75">
<asp:LinkButton id="lbuDeleteArticle" runat="server"
CommandName="Delete" CausesValidation="false">[Delete
Article]</asp:LinkButton>
</td></tr>
</ItemTemplate>

</asp:Repeater>

</ItemTemplate>
<SeparatorTemplate>
<tr><td valign="top" colspan="3">
<hr /></td></tr>
</SeparatorTemplate>
</asp:Repeater>

VB.net Code
-----------
Sub Page_Load
rptArticleGroup.DataSource = ds
rptArticleGroup.DataMember = "ArticleGroups"
rptArticleGroup.DataBind()
End Sub

Sub rptArticleGroup_ItemDataBound

rptArticles = CType(e.Item.FindControl("rptArticles "), Repeater)

If Not IsNothing(rptArticles ) Then
AddHandler rptArticles.ItemCommand, AddressOf rptArticles_ItemCommand
AddHandler rptArticles.ItemDataBound, AddressOf
rptArticles_ItemDataBound

rptArticles.DataSource = ds
rptArticles.DataMember = "Articles"
rptArticles.DataBind()
End if

End Sub

Sub rptArticles_ItemDataBound

lbuDeleteArticle= CType(e.Item.FindControl("lbuDeleteArticle"),
LinkButton)
If Not IsNothing(lbuDeleteArticle) Then
lbuDeleteArticle.Attributes.Add("onclick", "return confirm('Är Are
you sure you want to delete this?');")
End If

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top