473,769 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid command events not firing.

I have an interesting problem with a datagrid. It is the standard
chicken-and-the-egg problem.

I have this page with two datagrids. It essentially defines a parent-child
relationship. The parent grid has a "edit" and "delete" columns. When the
"edit" link button is clicked, I want the child grid to display some
information related to the parent. Now the child grid also has some command
buttons.

My problem is that I cannot get the child grid to responded to the command
events. The handlers are never invoked. Here is what I think the problem
is. In order for the handlers to be invoked, the object model for the past
must be the same on postback as was sent to the browser. That means that I
have to initialize both grids their Init events so the command handlers will
be invoked. The problem is, that when the parent grid's edit button is
clicked, the Init fires as expected, but I do not know the ID for the item
that was selected until the EditCommand handler is invoked. At this point,
I could bind the grid and render the appropriate list items. But, if I do
this, then if a command link is clicked on the child grid, the events do not
fire since the grid was not built in the Init event.

Any ideas at how I can solve this, assuming I made any sense?
Nov 19 '05 #1
1 2103
One of my co-workers just ran into this problem yesterday.

First, make sure the sub that should fire has the 'handles' directive at
the very right of the 'sub ...' line.

For example:
Private Sub DataGrid1_EditC ommand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
DataGrid1.EditC ommand
Also .. be sure you are NOT binding the datagrid on post-backs.

If you are running code (or calling a sub) in the page_load that does
your data-binding, be sure to exclude it from postbacks. Like this:

If Not IsPostBack Then
.. DB CODE ..
End If

Hope that helps,
Ricky

Peter Rilling wrote:
I have an interesting problem with a datagrid. It is the standard
chicken-and-the-egg problem.

I have this page with two datagrids. It essentially defines a parent-child
relationship. The parent grid has a "edit" and "delete" columns. When the
"edit" link button is clicked, I want the child grid to display some
information related to the parent. Now the child grid also has some command
buttons.

My problem is that I cannot get the child grid to responded to the command
events. The handlers are never invoked. Here is what I think the problem
is. In order for the handlers to be invoked, the object model for the past
must be the same on postback as was sent to the browser. That means that I
have to initialize both grids their Init events so the command handlers will
be invoked. The problem is, that when the parent grid's edit button is
clicked, the Init fires as expected, but I do not know the ID for the item
that was selected until the EditCommand handler is invoked. At this point,
I could bind the grid and render the appropriate list items. But, if I do
this, then if a command link is clicked on the child grid, the events do not
fire since the grid was not built in the Init event.

Any ideas at how I can solve this, assuming I made any sense?

Nov 19 '05 #2

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

Similar topics

0
2279
by: Timothy Elvidge | last post by:
I have an DataGrid with AutoGenerateColumns False and two controls defined for OnSort a third column contains a ButtonColum to add items to a basket.None of the relevant eventhandlers fire. I have checked the source of the page and there is javascript enabling the Postback, a Postback does occur and the Page_Load event fires but none of the subsequent DataGrid events? What's next in terms of debugging etc to find out why the events aren't...
5
12237
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
8
1714
by: Brent Burkart | last post by:
My datagrid OnCancelCommand event is not firing. HTML OnCancelCommand="AdminGrid_Cancel" 'Code Behind Sub AdminGrid_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) AdminGrid.EditItemIndex = -1 BindData()
2
336
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" runat="server" Width="100%" AutoGenerateColumns="False" HeaderStyle-CssClass="datagridheader" PagerStyle-Visible="False" DataKeyField="referralID" AllowSorting="True" OnSortCommand="SortSales"
2
3150
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional sorting as well as paging of the datagrid records.
1
1667
by: Stu | last post by:
Hi, I have a button in the footer of a datagrid that sometimes does not tigger the item command. The page is quite large & has a number of homegrown controls in it. Has anyone come across this type of behaviour before? Can anyone suggest a solution? Thanks in advance, Stu
2
3375
by: Deepesh | last post by:
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
2
1685
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 datagrid I do have the OnItemCommand propert set. <asp: Datagrid id="DataGrid1" runat="server" OnItemCommand="gStarted"> In the code the function is:
2
3336
by: AdrEsqu | last post by:
I am trying to use AutoPostback to retrieve the value that was selected in my dropdownlist. The event is not firing for the dropdownlist because the datagrid is being built after the Lifecycle of the Firing Events. So in order to capture my selected value I need to capture it in the OnInit when the autopostback fires, but I don't know how I can do this. Since the Page Lifecycle fires events before my datagrid gets built then I can...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9416
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,...
1
9979
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
8861
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...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.