Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Raising ItemCommand event from a DataGrid nested in a DataList

Reply
Thread Tools

Raising ItemCommand event from a DataGrid nested in a DataList

 
 
Matthew
Guest
Posts: n/a
 
      05-18-2004
I have a DataGrid nested within a DataList. The DataGrid generates
LinkButtons with specific CommandName values. I cannot figure out how
to trap this event. I need to know which DataGrid LinkButton was
selected.

Thanks in advance.
 
Reply With Quote
 
 
 
 
Vaibhav
Guest
Posts: n/a
 
      05-18-2004
give the link button on the datagrid a command name Like
CommandName="DeleteClick" and then in the itemcommand event for the datagrid
check for the command name like
Private Sub dg_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgWires.ItemCommand

If e.CommandName="DeleteClick" Then

End If

End Sub

HTH

"Matthew" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have a DataGrid nested within a DataList. The DataGrid generates
> LinkButtons with specific CommandName values. I cannot figure out how
> to trap this event. I need to know which DataGrid LinkButton was
> selected.
>
> Thanks in advance.



 
Reply With Quote
 
 
 
 
Matthew Ward
Guest
Posts: n/a
 
      05-18-2004
The issue is that DataGrid is nested within a DataList.
Therefore when you try to hook the event up (In InitializeComponent())
using

this.instancesGrid.ItemCommand += new
DataGridCommandEventHandler(InstancesGrid_ItemComm and);

you'll get a "Object reference not set to an instance of an object."
error. That's because the grid doesn't exist yet. Therefore, I've
tried to wait to hook up the event until the parent DataList
ItemDataBound event.

In the ItemDataBound event I had this code:
((DataGrid)e.Item.FindControl("instancesGrid")).It emCommand += new
DataGridCommandEventHandler(InstancesGrid_ItemComm and);

Although that won't cause an error to be raised, it will not call the
method I'm trying to call (InstancesGrid_ItemCommand). It does call
some event because I can see the page postback, but I'm not sure what
event that is.

Thanks for your help.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
ComputerGuru ComputerGuru is offline
Junior Member
Join Date: May 2010
Posts: 1
 
      05-19-2010
I know this is a 6-year old question, but I wanted to post a link to a blog article I wrote on how to solve this. It's very easy, and just requires the event to be attached at the ASPX level.

Since I can't post the direct link to my blog because of velocity review's stupid 50-post limit, just do a search on Google for "geekteligence datagrid".
 
Reply With Quote
 
joseOZ joseOZ is offline
Junior Member
Join Date: May 2010
Posts: 1
 
      05-26-2010
wow, i really DONT like registering en every forum i visit.
BUT i decided to registar en this just to tell you TNX.

this msg is for AAAAAALL administrators of forosdelweb.com
that dont let you reply on a post of some months old.

when i begin to read this page, i saw 2004 and i say THIS WILL
NOT HELP, but when i saw you post 2010, i feel great.

TNX for your info. this really helped.

and i think 50post limit is stpid too
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Retrieving the DataItem property in DataList's ItemCommand or SelectedIndexChanged event Nathan Sokalski ASP .Net Building Controls 1 09-13-2007 04:45 PM
Retrieving the DataItem property in DataList's ItemCommand or SelectedIndexChanged event Nathan Sokalski ASP .Net Web Controls 1 09-13-2007 04:45 PM
Retrieving the DataItem property in DataList's ItemCommand or SelectedIndexChanged event Nathan Sokalski ASP .Net 1 09-13-2007 04:45 PM
Problem with nested Repeater and ItemCommand Event Patrik Persson ASP .Net 0 08-30-2004 09:30 AM
ImageCommand doesn't fire DataList.ItemCommand() event Jeremy ASP .Net 0 07-02-2004 05:35 PM



Advertisments