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
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