471,354 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Datagrid ItemCommand Event Not Firing

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!
Nov 19 '05 #1
2 3224
Have you set the UpDateCommand etc in your DataGrid?
Patrick
"Deepesh" <De*****@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
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!

Nov 19 '05 #2
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" <De*****@discussions.microsoft.com> wrote in message
news:EA**********************************@microsof t.com...
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!


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Colin Ramsay | last post: by
2 posts views Thread by vinay | last post: by
5 posts views Thread by Jeff User | last post: by
2 posts views Thread by Lagwagon | last post: by
3 posts views Thread by Mark Gilkes | last post: by
1 post views Thread by Mark Gilkes | last post: by
1 post views Thread by kevin | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.