Datagrid ItemCommand Event Not Firing

Discussion in 'ASP .Net' started by =?Utf-8?B?RGVlcGVzaA==?=, Oct 5, 2005.

  1. Good day, I have a specific case of the DataGrid in my solution which is
    causing the ItemCommand Event Not Firing.

    So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX
    file and .CS file. When I initialize my .CS file, in that code there is a
    method that goes:

    Page.LoadControl(FILENAME)

    Which associates a .ascx file with my .CS file, allowing me to plug in any
    filename to change the presentation of my user control. Then, I get access to
    each control in the user control by

    SomeControl = skin.FindControl("NameOfControl").

    - As such, one of the controls here is a DataGrid. In the .ascx part of this
    solution, I have a <TemplateColumn>, in which <ItemColumn><asp: Button
    id="Save" Command="Edit" runat=server></ItemColumn> and <EditItemColumn><asp:
    Button id="Edit" Command="Edit" runat=server></EditItemColumn>

    - In my .cs file, I DataBind() everytime. If I don't do this, when I click
    any button on the datagrid, the datagrid disappears on the postback.

    - I have event handler associated with the ItemCommand event for the dg.
    Each case of the event handler also calls DataBind()

    THE PROBLEM
    - When I click the Edit button, the "Edit" ItemCommand Event is fired, and
    since i'm changing the "EditItemIndex", the datagrid switches to edit mode,
    and now I can see my "Save" button.
    - HOWEVER, when I now click "Save", no ItemCommand Event is fired for some
    peculiar reason. This is what I need help with.

    For some reason the events are getting lost. If someone can help me out with
    finding out why they are getting lost, or how to track what events are on the
    "queue", it would be greatly appreciated.

    also --- i tried using a <EditButtonColumn>, and I get some strange behavior
    here too. When I click Edit, it emits a "Edit" command. Fine. But when I
    subsequently click "Save", it emits a "Edit" command again ... ! Also, when I
    click "Cancel", it emits no command.

    Please Help!
    =?Utf-8?B?RGVlcGVzaA==?=, Oct 5, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?RGVlcGVzaA==?=

    Patirck Ige Guest

    Have you set the UpDateCommand etc in your DataGrid?
    Patrick


    "Deepesh" <> wrote in message
    news:...
    > Good day, I have a specific case of the DataGrid in my solution which is
    > causing the ItemCommand Event Not Firing.
    >
    > So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX
    > file and .CS file. When I initialize my .CS file, in that code there is a
    > method that goes:
    >
    > Page.LoadControl(FILENAME)
    >
    > Which associates a .ascx file with my .CS file, allowing me to plug in any
    > filename to change the presentation of my user control. Then, I get access

    to
    > each control in the user control by
    >
    > SomeControl = skin.FindControl("NameOfControl").
    >
    > - As such, one of the controls here is a DataGrid. In the .ascx part of

    this
    > solution, I have a <TemplateColumn>, in which <ItemColumn><asp: Button
    > id="Save" Command="Edit" runat=server></ItemColumn> and

    <EditItemColumn><asp:
    > Button id="Edit" Command="Edit" runat=server></EditItemColumn>
    >
    > - In my .cs file, I DataBind() everytime. If I don't do this, when I click
    > any button on the datagrid, the datagrid disappears on the postback.
    >
    > - I have event handler associated with the ItemCommand event for the dg.
    > Each case of the event handler also calls DataBind()
    >
    > THE PROBLEM
    > - When I click the Edit button, the "Edit" ItemCommand Event is fired, and
    > since i'm changing the "EditItemIndex", the datagrid switches to edit

    mode,
    > and now I can see my "Save" button.
    > - HOWEVER, when I now click "Save", no ItemCommand Event is fired for some
    > peculiar reason. This is what I need help with.
    >
    > For some reason the events are getting lost. If someone can help me out

    with
    > finding out why they are getting lost, or how to track what events are on

    the
    > "queue", it would be greatly appreciated.
    >
    > also --- i tried using a <EditButtonColumn>, and I get some strange

    behavior
    > here too. When I click Edit, it emits a "Edit" command. Fine. But when I
    > subsequently click "Save", it emits a "Edit" command again ... ! Also,

    when I
    > click "Cancel", it emits no command.
    >
    > Please Help!
    Patirck Ige, Oct 6, 2005
    #2
    1. Advertising

  3. I am assigning the ItemCommand Event Handler dynamically, ie in my .cs file.
    And yes, all my <asp:button> have CommandName="Update", "Edit", or "Cancel"
    and I have a switch e.CommandName statement in my event handler...

    "Patirck Ige" wrote:

    > Have you set the UpDateCommand etc in your DataGrid?
    > Patrick
    >
    >
    > "Deepesh" <> wrote in message
    > news:...
    > > Good day, I have a specific case of the DataGrid in my solution which is
    > > causing the ItemCommand Event Not Firing.
    > >
    > > So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX
    > > file and .CS file. When I initialize my .CS file, in that code there is a
    > > method that goes:
    > >
    > > Page.LoadControl(FILENAME)
    > >
    > > Which associates a .ascx file with my .CS file, allowing me to plug in any
    > > filename to change the presentation of my user control. Then, I get access

    > to
    > > each control in the user control by
    > >
    > > SomeControl = skin.FindControl("NameOfControl").
    > >
    > > - As such, one of the controls here is a DataGrid. In the .ascx part of

    > this
    > > solution, I have a <TemplateColumn>, in which <ItemColumn><asp: Button
    > > id="Save" Command="Edit" runat=server></ItemColumn> and

    > <EditItemColumn><asp:
    > > Button id="Edit" Command="Edit" runat=server></EditItemColumn>
    > >
    > > - In my .cs file, I DataBind() everytime. If I don't do this, when I click
    > > any button on the datagrid, the datagrid disappears on the postback.
    > >
    > > - I have event handler associated with the ItemCommand event for the dg.
    > > Each case of the event handler also calls DataBind()
    > >
    > > THE PROBLEM
    > > - When I click the Edit button, the "Edit" ItemCommand Event is fired, and
    > > since i'm changing the "EditItemIndex", the datagrid switches to edit

    > mode,
    > > and now I can see my "Save" button.
    > > - HOWEVER, when I now click "Save", no ItemCommand Event is fired for some
    > > peculiar reason. This is what I need help with.
    > >
    > > For some reason the events are getting lost. If someone can help me out

    > with
    > > finding out why they are getting lost, or how to track what events are on

    > the
    > > "queue", it would be greatly appreciated.
    > >
    > > also --- i tried using a <EditButtonColumn>, and I get some strange

    > behavior
    > > here too. When I click Edit, it emits a "Edit" command. Fine. But when I
    > > subsequently click "Save", it emits a "Edit" command again ... ! Also,

    > when I
    > > click "Cancel", it emits no command.
    > >
    > > Please Help!

    >
    >
    >
    =?Utf-8?B?RGVlcGVzaA==?=, Oct 6, 2005
    #3
    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. EvelynAnd Ethan
    Replies:
    4
    Views:
    973
    =?Utf-8?B?Sko=?=
    Jan 9, 2006
  2. =?Utf-8?B?ZGFuYw==?=

    DataGrid ItemCommand event not firing if not first page

    =?Utf-8?B?ZGFuYw==?=, Oct 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,148
    =?Utf-8?B?ZGFuYw==?=
    Oct 26, 2005
  3. Andy
    Replies:
    0
    Views:
    415
  4. PD
    Replies:
    0
    Views:
    376
  5. John

    ImageButton not firing ItemCommand event for the datagrid

    John, Aug 4, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    289
Loading...

Share This Page