Usercontrol with Repeater not firing the repeater's Item

Posted by Community Admin on 04-Aug-2018 03:56

Usercontrol with Repeater not firing the repeater's ItemCommand event

All Replies

Posted by Community Admin on 10-Jan-2012 00:00

I am using SF 4.4, upgraded from 4.3 and utilizing a custom usercontrol (.ascx) as a widget template to display a document list with some logic behind it. The custom template works perfect except nothing I do per all the other posts I've seen around the web on this issue seems to get the repeater's ItemCommand event to fire. Viewstate IS enabled for the page this user control is in and I have set the "OnItemCommand" for the repeater.  I do not have anything else happening in the codebehind at this point and have stripped it all out trying to get this to work.  Thoughts??

Below is my code.

Protected Sub documentsRepeater_ItemCommand(source As Object, e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles documentsRepeater.ItemCommand
 
If e.CommandName = "requestResource" then
'//do something
End If
 
End Sub

<%@ Control Language="VB" AutoEventWireup="true" CodeFile="OpenAccessDataProvider,57D8E0F28B3D4CBF96A4000000000001.ascx.vb"
    Inherits="SfCtrlPresentation_OpenAccessDataProvider_57D8E0F28B3D4CBF96A4000000000001"
    EnableViewState="True" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit"
    Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sitefinity" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<sitefinity:ResourceLinks ID="resourcesLinks2" runat="server" UseEmbeddedThemes="true"
    Theme="Default">
    <sitefinity:ResourceFile Name="Telerik.Sitefinity.Resources.Themes.Basic.Styles.icons.css"
        Static="true" />
</sitefinity:ResourceLinks>
<sf:BrowseAndEditToolbar ID="browseAndEditToolbar" runat="server" Mode="Edit">
</sf:BrowseAndEditToolbar>
<div id="itemsContainer" class="articles" runat="server">
    <asp:Repeater ID="documentsRepeater" runat="server" OnItemCommand="documentsRepeater_ItemCommand">
        <HeaderTemplate>
            <ul class="articles sfListMode">
        </HeaderTemplate>
        <ItemTemplate>
            <li id="docItem" runat="server" class="article separator sfdownloadFile">
                <h3>
                    <%# Eval("Title")%></h3>
                <%# Eval("Description") %><br />
                <asp:Button runat="server" ID="btnDownload" Text="Download" CausesValidation="False"
                    CommandName="requestResource" CommandArgument='<%# Eval("Id") %>'></asp:Button>
            </li>
        </ItemTemplate>
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>
</div>
<sitefinity:Pager ID="pager" runat="server">
</sitefinity:Pager>

Posted by Community Admin on 15-Jan-2012 00:00

Hello Craig,

Thank you for using our services. We have tried using the provided control on several local Sitefinity projects, and had no problems hitting the breakpoint in ItemCommand event of the repeater. Can you please check if the problem reproduces in a clear Sitefinity page, and if it doesn't are there any specific controls on the current page that might interfere with the repeater's functionality?
If any problems persist, can you please try substituting the Repeater control with our RadListView, which should serve equivalent functionality, and let us know if the problem reproduces with it as well? Thanks in advance for your kind cooperation,

Regards,
Boyan Barnev
the Telerik team
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
 

Posted by Community Admin on 19-Jan-2012 00:00

Hi Boyan,

How can I reference a control within the detailContainer? I've tried using detailContainer.FindControl("controlName") under detailContainer_DataBound event with no luck - just "object reference not found."

Posted by Community Admin on 20-Jan-2012 00:00

Hi,

If you're not referencing the control inside an event handler but rather in a class you can use GetControl<T> for example:

protected internal virtual RadListView DocumentsList
        
            get
            
                return this.Container.GetControl<RadListView>("DocumentsList", true);
            
        
on the other side, if you're subscribing to an event, you might need to call FindControl, for example:
var quantityControl = e.Item.FindControl("QuantityBox") as TextBox;

I was not able to find a control with ID detailContainer to demonstrate how you can achieve the desired functionality on the sample template you've sent me, could it be that you are referencing another template, or have changed the controls naming?


All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed