473,396 Members | 1,968 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,396 software developers and data experts.

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_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand
pi_dsUser.WriteXml(Server.MapPath("Datafiles\Users .xml"))
DataGrid1.DataBind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False"
Width="656px" EnableViewState="False" OnCancelCommand =
"DataGrid1_CancelCommand" OnUpdateCommand = "DataGrid1_UpdateCommand"
OnEditCommand = "DataGrid1_EditCommand">
<Columns>
<asp:BoundColumn <asp:BoundColumn HeaderText="Name"
DataField="US_Name" ReadOnly="False"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit" ></asp:EditCommandColumn>
</Columns></asp:datagrid>
any suggestions will be highly appreciated ....
cheers,
siaj
Nov 19 '05 #1
3 1687
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_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand
pi_dsUser.WriteXml(Server.MapPath("Datafiles\Users .xml"))
DataGrid1.DataBind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False"
Width="656px" EnableViewState="False" OnCancelCommand =
"DataGrid1_CancelCommand" OnUpdateCommand = "DataGrid1_UpdateCommand"
OnEditCommand = "DataGrid1_EditCommand">
<Columns>
<asp:BoundColumn <asp:BoundColumn HeaderText="Name"
DataField="US_Name" ReadOnly="False"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit" ></asp:EditCommandColumn>
</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********@hotmail.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_EditCommand(ByVal source As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridCommandEventArg s) HandlesDataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_CancelCommand(ByVal source As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridCommandEventArg s) HandlesDataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridCommandEventArg s) HandlesDataGrid1.UpdateCommand
pi_dsUser.WriteXml(Server.MapPath ("Datafiles\Users.xml")) DataGrid1.DataBind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False"Width="656px" EnableViewState="False" OnCancelCommand =
"DataGrid1_CancelCommand" OnUpdateCommand = "DataGrid1_UpdateCommand"OnEditCommand = "DataGrid1_EditCommand">
<Columns>
<asp:BoundColumn <asp:BoundColumn HeaderText="Name"DataField="US_Name" ReadOnly="False"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update"CancelText="Cancel" EditText="Edit"
</asp:EditCommandColumn>
</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\cancel) as Private. I had to keep it Public as Keeping the
events private gives compliation error "...Private Sub
DataGrid1_UpdateCommand(source As Object, e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) 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********@hotmail.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_EditCommand(ByVal source As Object,

ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArg s)

Handles
DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_CancelCommand(ByVal source As

Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArg s)

Handles
DataGrid1.CancelCommand
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
End Sub

Public Sub DataGrid1_UpdateCommand(ByVal source As

Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArg s)

Handles
DataGrid1.UpdateCommand
pi_dsUser.WriteXml(Server.MapPath

("Datafiles\Users.xml"))
DataGrid1.DataBind()
End Sub

My HTML code for datagrid looks like..

<asp:datagrid id="DataGrid1" runat="server"

AutoGenerateColumns="False"
Width="656px" EnableViewState="False" OnCancelCommand =
"DataGrid1_CancelCommand" OnUpdateCommand

= "DataGrid1_UpdateCommand"
OnEditCommand = "DataGrid1_EditCommand">
<Columns>
<asp:BoundColumn

<asp:BoundColumn HeaderText="Name"
DataField="US_Name" ReadOnly="False"></asp:BoundColumn>

<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update"
CancelText="Cancel" EditText="Edit"
</asp:EditCommandColumn>
</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
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...
13
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...
0
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....
1
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...
4
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...
5
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...
6
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...
1
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...
4
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
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...

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.