473,799 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datatgrid Event Not firing

Hello I hv a datagrid in my ASP.NET page. I hv a edit column The edit command
gets fired(even if i dont add ONEditcommand in HTML code) but the
cancel/update command does not gets fired although I hv code for
Onedit/cancle/update (It always goes to Edit commnad event)

My Codebehind is as :
Public Sub DataGrid1_EditC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.EditC ommand
DataGrid1.EditI temIndex = e.Item.ItemInde x
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Cance lCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Cance lCommand
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Updat eCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Updat eCommand
pi_dsUser.Write Xml(Server.MapP ath("Datafiles\ Users.xml"))
DataGrid1.DataB ind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False"
Width="656px" EnableViewState ="False" OnCancelCommand =
"DataGrid1_Canc elCommand" OnUpdateCommand = "DataGrid1_Upda teCommand"
OnEditCommand = "DataGrid1_Edit Command">
<Columns>
<asp:BoundColum n <asp:BoundColum n HeaderText="Nam e"
DataField="US_N ame" ReadOnly="False "></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate"
CancelText="Can cel" EditText="Edit" ></asp:EditCommand Column>
</Columns></asp:datagrid>
any suggestions will be highly appreciated ....
cheers,
siaj
Nov 19 '05 #1
3 1706
I have had this same problem numerous times. I have always found that the
problem is one of 2 things...
I have do something which destroys the event, typically this would be
"re-binding" the grid in "postback" event.
The second reason is that I typically have the datagrid tied to a dataview
and You have to set the datasource in the "Page PostBack" or the event will
not fire.

Like I said, These are the situations where it has happended to me and I
would guess yours would fall into one of these two situations.

"siaj" wrote:
Hello I hv a datagrid in my ASP.NET page. I hv a edit column The edit command
gets fired(even if i dont add ONEditcommand in HTML code) but the
cancel/update command does not gets fired although I hv code for
Onedit/cancle/update (It always goes to Edit commnad event)

My Codebehind is as :
Public Sub DataGrid1_EditC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.EditC ommand
DataGrid1.EditI temIndex = e.Item.ItemInde x
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Cance lCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Cance lCommand
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Updat eCommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.Updat eCommand
pi_dsUser.Write Xml(Server.MapP ath("Datafiles\ Users.xml"))
DataGrid1.DataB ind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateCol umns="False"
Width="656px" EnableViewState ="False" OnCancelCommand =
"DataGrid1_Canc elCommand" OnUpdateCommand = "DataGrid1_Upda teCommand"
OnEditCommand = "DataGrid1_Edit Command">
<Columns>
<asp:BoundColum n <asp:BoundColum n HeaderText="Nam e"
DataField="US_N ame" ReadOnly="False "></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate"
CancelText="Can cel" EditText="Edit" ></asp:EditCommand Column>
</Columns></asp:datagrid>
any suggestions will be highly appreciated ....
cheers,
siaj

Nov 19 '05 #2
You might set EnableViewState to false, it causes only
trouble of firing Cancel/Update event (all goes to Edit
event).

HTH,

Elton Wang
el********@hotm ail.com

-----Original Message-----
Hello I hv a datagrid in my ASP.NET page. I hv a edit column The edit commandgets fired(even if i dont add ONEditcommand in HTML code) but thecancel/update command does not gets fired although I hv code forOnedit/cancle/update (It always goes to Edit commnad event)
My Codebehind is as :
Public Sub DataGrid1_EditC ommand(ByVal source As Object, ByVal e AsSystem.Web.UI. WebControls.Dat aGridCommandEve ntArgs) HandlesDataGrid1.Edit Command
DataGrid1.EditI temIndex = e.Item.ItemInde x
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Cance lCommand(ByVal source As Object, ByVal e AsSystem.Web.UI. WebControls.Dat aGridCommandEve ntArgs) HandlesDataGrid1.Canc elCommand
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Updat eCommand(ByVal source As Object, ByVal e AsSystem.Web.UI. WebControls.Dat aGridCommandEve ntArgs) HandlesDataGrid1.Upda teCommand
pi_dsUser.Write Xml(Server.MapP ath ("Datafiles\Use rs.xml")) DataGrid1.DataB ind()
End Sub

My HTML code for datagrid looks like..

<asp:datagri d id="DataGrid1" runat="server" AutoGenerateCol umns="False"Width="656px " EnableViewState ="False" OnCancelCommand =
"DataGrid1_Can celCommand" OnUpdateCommand = "DataGrid1_Upda teCommand"OnEditComman d = "DataGrid1_Edit Command">
<Columns>
<asp:BoundColum n <asp:BoundColum n HeaderText="Nam e"DataField="US_ Name" ReadOnly="False "></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton"
UpdateText="Upd ate"CancelText="Ca ncel" EditText="Edit"
</asp:EditCommand Column>
</Columns></asp:datagrid>
any suggestions will be highly appreciated ....
cheers,
siaj
.

Nov 19 '05 #3
Thanks Guys.. I tried setting the enableviewstate = True and The event are
getting fired.

In the same league ...wanted to know cant I keep the events
(Edit\update\ca ncel) as Private. I had to keep it Public as Keeping the
events private gives compliation error "...Private Sub
DataGrid1_Updat eCommand(source As Object, e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) is not accessible in this
context because it is 'Private'.

cheers,
siaj
"Elton Wang" wrote:
You might set EnableViewState to false, it causes only
trouble of firing Cancel/Update event (all goes to Edit
event).

HTH,

Elton Wang
el********@hotm ail.com

-----Original Message-----
Hello I hv a datagrid in my ASP.NET page. I hv a edit

column The edit command
gets fired(even if i dont add ONEditcommand in HTML code)

but the
cancel/update command does not gets fired although I hv

code for
Onedit/cancle/update (It always goes to Edit commnad

event)

My Codebehind is as :
Public Sub DataGrid1_EditC ommand(ByVal source As Object,

ByVal e As
System.Web.UI. WebControls.Dat aGridCommandEve ntArgs)

Handles
DataGrid1.Edit Command
DataGrid1.EditI temIndex = e.Item.ItemInde x
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Cance lCommand(ByVal source As

Object, ByVal e As
System.Web.UI. WebControls.Dat aGridCommandEve ntArgs)

Handles
DataGrid1.Canc elCommand
DataGrid1.EditI temIndex = -1
DataGrid1.DataB ind()
End Sub

Public Sub DataGrid1_Updat eCommand(ByVal source As

Object, ByVal e As
System.Web.UI. WebControls.Dat aGridCommandEve ntArgs)

Handles
DataGrid1.Upda teCommand
pi_dsUser.Write Xml(Server.MapP ath

("Datafiles\Use rs.xml"))
DataGrid1.DataB ind()
End Sub

My HTML code for datagrid looks like..

<asp:datagri d id="DataGrid1" runat="server"

AutoGenerateCol umns="False"
Width="656px " EnableViewState ="False" OnCancelCommand =
"DataGrid1_Can celCommand" OnUpdateCommand

= "DataGrid1_Upda teCommand"
OnEditComman d = "DataGrid1_Edit Command">
<Columns>
<asp:BoundColum n

<asp:BoundColum n HeaderText="Nam e"
DataField="US_ Name" ReadOnly="False "></asp:BoundColumn >

<asp:EditComman dColumn ButtonType="Lin kButton"
UpdateText="Upd ate"
CancelText="Ca ncel" EditText="Edit"
</asp:EditCommand Column>
</Columns></asp:datagrid>
any suggestions will be highly appreciated ....
cheers,
siaj
.

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
22022
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages on different menu forms. Details: frmTRNMenu is the main menu of the application. It uses tabbed pages to logically separate menu items. The last tab on the list is different - it has an image and then "O&M". Clicking on this last page will...
13
7501
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
0
1694
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button. When the login is successful login page writes back javascript
1
5063
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was testing this, I noticed that the OnCurrent event wasn't firing. I went to an older version of the program and saw that it wasn't firing there either. I don't know how long this has been going on, but it's quite distressing. To test the firing, I...
4
4203
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it would be initialized and have its event handlers set up, then after Load, the control would call its...
5
4546
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the onmouseleave / onmouseout event I've attached to my hidden drop down (in this case an <ul>), is not firing correctly. It seems that when the mouse enters the ul it fires the mouseleave event. The problem is in the hideMenu2(e) function. I'm copying...
6
19272
by: sjoshi | last post by:
I have a derived class OraBackup which has a method that calls stored procedure on Oracledb to get status of backup job. Now the base class publishes an event like this: public delegate void PercentEventHandler(object sender, JobCompletedEventArgs e); public event PercentEventHandler PercentCompleted; And fires it:
1
2871
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the following code to execute. But the page load event is not firing. I tried , the same function rewriten in C#, then page load event worked absolutely fine. I dont know why the page load event is not firing in VB.net . Could some one try please try my same...
4
2048
by: Joergen Bech | last post by:
I sometimes use delegates for broadcasting "StateChanged" events, i.e. if I have multiple forms and/or controls that need updating at the same time as the result of a change in a global/common object, I keep local references to this object in each UI object, e.g. Private WithEvents _tools As RepeatTools and catch messages in an event handler like this:
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.