Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Problem with nested Repeater and ItemCommand Event

 
Thread Tools Search this Thread
Old 08-30-2004, 10:30 AM   #1
Default Problem with nested Repeater and ItemCommand Event


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


Patrik Persson
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46