ItemCommand event does not fire???

Discussion in 'ASP .Net' started by Jimmy, May 27, 2005.

  1. Jimmy

    Jimmy Guest

    Hi,

    I built a webform with a repeater:

    <asp:repeater id="rep1" runat="server" DataSource='<%# ar %>'>
    <ItemTemplate>
    <asp:Button Runat=server Text="<%# Container.DataItem %>" ID="Button1"
    NAME="Button1"/>
    </ItemTemplate>
    </asp:repeater>

    in my code behind the webform I have
    -an array ar (which is not the problem here)
    -the ItemCommand event, which does not fire???:
    private void rep1_ItemCommand(object source,
    System.Web.UI.WebControls.RepeaterCommandEventArgs e)

    {

    //some code

    }



    If I try a asp:LinkButton instead of a asp:Button it DOES fire!!! So the
    question is why does this event not fire in case of the aspbutton??? You
    should be able to fire a button right???



    thanks



    JIM
     
    Jimmy, May 27, 2005
    #1
    1. Advertising

  2. Jimmy

    Bruce Barker Guest

    buttons don't support the ItemCommand event, because they do not use
    javascript to postback, so the ItemCommand hidden fields are not filled in.

    -- bruce (sqlwork.com)


    "Jimmy" <> wrote in message
    news:...
    > Hi,
    >
    > I built a webform with a repeater:
    >
    > <asp:repeater id="rep1" runat="server" DataSource='<%# ar %>'>
    > <ItemTemplate>
    > <asp:Button Runat=server Text="<%# Container.DataItem %>" ID="Button1"
    > NAME="Button1"/>
    > </ItemTemplate>
    > </asp:repeater>
    >
    > in my code behind the webform I have
    > -an array ar (which is not the problem here)
    > -the ItemCommand event, which does not fire???:
    > private void rep1_ItemCommand(object source,
    > System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    >
    > {
    >
    > //some code
    >
    > }
    >
    >
    >
    > If I try a asp:LinkButton instead of a asp:Button it DOES fire!!! So the
    > question is why does this event not fire in case of the aspbutton??? You
    > should be able to fire a button right???
    >
    >
    >
    > thanks
    >
    >
    >
    > JIM
    >
    >
     
    Bruce Barker, May 27, 2005
    #2
    1. Advertising

  3. Jimmy

    vMike Guest

    "Jimmy" <> wrote in message
    news:...
    > Hi,
    >
    > I built a webform with a repeater:
    >
    > <asp:repeater id="rep1" runat="server" DataSource='<%# ar %>'>
    > <ItemTemplate>
    > <asp:Button Runat=server Text="<%# Container.DataItem %>" ID="Button1"
    > NAME="Button1"/>
    > </ItemTemplate>
    > </asp:repeater>
    >
    > in my code behind the webform I have
    > -an array ar (which is not the problem here)
    > -the ItemCommand event, which does not fire???:
    > private void rep1_ItemCommand(object source,
    > System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    >
    > {
    >
    > //some code
    >
    > }
    >
    >
    >
    > If I try a asp:LinkButton instead of a asp:Button it DOES fire!!! So the
    > question is why does this event not fire in case of the aspbutton??? You
    > should be able to fire a button right???
    >
    >
    >
    > thanks
    >
    >
    >
    > JIM
    >

    I didn't see OnItemCommand="rep1_ItemCommand" in your repeater tagss!
     
    vMike, May 27, 2005
    #3
  4. Jimmy

    Jimmy Guest

    thanks guys
    I got it:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
    frlrfsystemwebuiwebcontrolsrepeaterclassonitemcommandtopic.asp

    "Jimmy" <> wrote in message
    news:...
    > Hi,
    >
    > I built a webform with a repeater:
    >
    > <asp:repeater id="rep1" runat="server" DataSource='<%# ar %>'>
    > <ItemTemplate>
    > <asp:Button Runat=server Text="<%# Container.DataItem %>"

    ID="Button1"
    > NAME="Button1"/>
    > </ItemTemplate>
    > </asp:repeater>
    >
    > in my code behind the webform I have
    > -an array ar (which is not the problem here)
    > -the ItemCommand event, which does not fire???:
    > private void rep1_ItemCommand(object source,
    > System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    >
    > {
    >
    > //some code
    >
    > }
    >
    >
    >
    > If I try a asp:LinkButton instead of a asp:Button it DOES fire!!! So the
    > question is why does this event not fire in case of the aspbutton??? You
    > should be able to fire a button right???
    >
    >
    >
    > thanks
    >
    >
    >
    > JIM
    >
    >
     
    Jimmy, May 28, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick Gilbert
    Replies:
    2
    Views:
    899
    Jeffrey Tan[MSFT]
    Dec 15, 2003
  2. Replies:
    3
    Views:
    2,663
    Karl Seguin
    Feb 7, 2005
  3. Nick Gilbert
    Replies:
    4
    Views:
    255
    Jeffrey Tan[MSFT]
    Dec 16, 2003
  4. thijs braem via .NET 247

    ItemCommand does not fire

    thijs braem via .NET 247, May 15, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    193
    thijs braem via .NET 247
    May 15, 2005
  5. Krushna

    Repeater ItemCommand does not fire the first time

    Krushna, Jul 29, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    184
    Krushna
    Jul 29, 2005
Loading...

Share This Page