PC Review


Reply
Thread Tools Rate Thread

datagrid command events not firing.

 
 
Peter Rilling
Guest
Posts: n/a
 
      1st Apr 2005
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?


 
Reply With Quote
 
 
 
 
Ricky Smith
Guest
Posts: n/a
 
      2nd Apr 2005
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_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.EditCommand


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?
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firing events for child controls in a DataGrid =?Utf-8?B?Z2xlbm4=?= Microsoft ASP .NET 2 19th Jul 2006 04:00 PM
datagrid postback events not firing from inside web user control Vikram Sinha Microsoft ASP .NET 0 12th Apr 2004 10:42 AM
DataGrid EditCommandColumn not firing events properly. Rick Microsoft ASP .NET 1 2nd Feb 2004 05:03 AM
DataGrid EditCommandColumn not firing events properly. Richard Ryerson Microsoft ASP .NET 0 28th Jan 2004 06:50 PM
Firing Datagrid events without maintaining ViewState Dinesh Upare Microsoft ASP .NET 0 16th Jul 2003 07:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:58 AM.