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

Raising ItemCommand event from a DataGrid nested in a DataList

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.
Nov 18 '05 #1
2 3271
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" <mw***@topflightconcepts.com> wrote in message
news:ed**************************@posting.google.c 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.

Nov 18 '05 #2
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!
Nov 18 '05 #3

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

Similar topics

0
by: Robert Brinson | last post by:
I have created a custom TextBox by inheriting TextBox. My purpose in this was so that I could raise a BubleEvent such that custom TextBoxes that are child controls of a DataGrid would actually...
2
by: Stan | last post by:
I cannot make the link buttons fire ItemCommand from repeater control. Here is the code: <asp:repeater id=rptLetters runat="server"> <itemtemplate> <asp:linkbutton id="lnkLetter"...
0
by: Marty U. | last post by:
I have two datalists nested. On the ItemDataBound Event of the first datalist I databind the second with specific info. A couple questions: 1) How can I utilize the OnItemCommand of the nested...
2
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...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
1
by: needin4mation | last post by:
Hi, I have a datalist. In this datalist I have a datagrid. The datalist is the master. The datagrid is the detail. It works fine. I populate the datagrid inside of the datalist using the...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
1
by: Nathan Sokalski | last post by:
I have a custom Control that I have made that contains a DataList. In either the ItemCommand or SelectedIndexChanged event I need to retrieve a value from the DataItem of the SelectedItem. I have...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
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,...
0
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...
0
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...

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.