I've looked around and found
this post and it hasn't helped a bit but cannot figure out why my ItemCommand isn't fired. I've got a pretty simple webpart as you can see below, on page load it displays a textbox and button. The user enters text and clicks the button and a search is performed. If there are results in the repeater, the ItemTemplate has a <asp:LinkButton> in it that should allow them to click it and fire the ItemCommand event. Lookup works great as usual, just not sure on the Repeater Events. Any ideas?
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SigSubs.ascx.cs" Inherits="CMSWebParts_MyWebParts_SigSubs" %>
<asp:Panel ID="pnlLookup" runat="server" DefaultButton="btnLookup">
<cms:LocalizedLabel ID="lblEmailOrCell" runat="server" />
<asp:TextBox ID="txtEmailOrCell" runat="server" /><br />
<cms:CMSButton ID="btnLookup" runat="server" CssClass="input-button" OnClick="btnLookup_Click" />
</asp:Panel>
<asp:Panel ID="pnlMessage" runat="server">
<cms:LocalizedLabel ID="lblMessage" runat="server" CssClass="errorLg" />
</asp:Panel>
<cms:CMSRepeater ID="rptItems" runat="server" OnItemCommand="rptItems_ItemCommand" />
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
/// <summary>
/// Initializes the control properties
/// </summary>
protected void SetupControl()
{
if (this.StopProcessing)
{
// Do nothing
}
else
{
lblMessage.Text = "";
// design properties
lblEmailOrCell.Text = LabelText;
btnLookup.Text = ButtonText;
// repeater properties
rptItems.AlternatingTransformationName = AlternatingTransformationName;
rptItems.TransformationName = TransformationName;
rptItems.HeaderTemplate = CMSDataProperties.LoadTransformation(this, HeaderTransformationName, true);
rptItems.FooterTemplate = CMSDataProperties.LoadTransformation(this, FooterTransformationName, true);
rptItems.SeparatorTemplate = CMSDataProperties.LoadTransformation(this, SeparatorTransformationName, true);
if (!String.IsNullOrEmpty(ZeroRowsText))
{
rptItems.ZeroRowsText = ZeroRowsText;
}
rptItems.HideControlForZeroRows = HideControlForZeroRows;
if (!RequestHelper.IsPostBack())
{
rptItems.ZeroRowsText = "";
}
}
}
/// <summary>
/// Reloads data
/// </summary>
public override void ReloadData()
{
base.ReloadData();
}
#endregion
#region "Events"
protected void btnLookup_Click(object sender, EventArgs e)
{
DoLookUp();
}
protected void rptItems_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
// do some work here
// then databind
DoLookUp();
}
#endregion
#region "Private methods"
private void DoLookUp()
{
// do some work here
rptItems.DataSource = ds;
rptItems.DataBind();
}