473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3341
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Colin Ramsay | last post by:
Hi all, I don't normally post swathes of code like this but I am truly banging my head off my desk here... I've dynamically created a datagrid within a usercontrol. There are two columns...
2
by: vinay | last post by:
I implemented paging on this grid OnPageIndexChanged="dgSales_Page" When i click Next page, it is firing OnItemCommand insted of OnPageIndexChanged ??? <asp:datagrid id="dgSales"...
3
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
2
by: Lagwagon | last post by:
I have an Image Button inside of a Datagrid and its not firing the datagrid.itemcommand event when it is clicked. Does anyone have a link to a tutorial or a solution for this problem? For my...
3
by: Mark Gilkes | last post by:
Hi, I have an aspx page in which I am building a DataGrid control in the code-behind dynamically. The DataGrid is declared along with BoundColumns and bound to the datasource, then added to a...
1
by: Mark Gilkes | last post by:
I have a DataGrid which I am adding to the page dynamically at the Init stage of the page load. The DataGrid has AutoGenerateColumns turned off, has BoundColumns and is bound to a DataView for...
1
by: kevin | last post by:
Hi, I'm working with VS 2005 and Framework 2.0 I have a datagrid with a link and the selectedindexchanged will not fire. The page posts back but does nothing. Protected Sub...
0
by: Andy | last post by:
Probably this quesion was already raised, but I couldn't find any answer to it, even on Google. My question is: I have a plain datagrid on a page, and I'm adding a button column to it. When...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.