473,608 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested Buttons & Event Handlers in DataList/Grid not working

Hi. I'm trying to make some event handlers for buttons that are nested
within datalists, however I keep getting errors trying to access them and a
blank page shows w/o any real error message. How can I access these nested
controls correctly?

For some reason I always have to use a foreach loop to search for a control
within a control. Using FindControl() from the top level does not work and
returns a "reference not set to an instance of an object" error because the
control can't be found w/o going through the children controls first, at
least that's what I assume.

Here is part of the code:
private void InitializeCompo nent()
{
// Assign/Load event handlers
dlEmployeeProfi le.EditCommand += new
DataListCommand EventHandler(dl EmployeeProfile _EditCommand);
dlEmployeeProfi le.ItemCommand += new
DataListCommand EventHandler(dl EmployeeProfile _ItemCommand);

// Find controls and assign event handlers
foreach (Control dlEmployeeProfi leControl in
dlEmployeeProfi le.Controls)
{
Button btnStartDate =
(Button)dlEmplo yeeProfile.Find Control("btnSta rtDate");
btnStartDate.Co mmand += new
CommandEventHan dler(dlEmployee Profile_Command );
Button btnEndDate =
(Button)dlEmplo yeeProfile.Find Control("btnEnd Date");
btnEndDate.Comm and += new
CommandEventHan dler(dlEmployee Profile_Command );
}

Load += new EventHandler(Pa ge_Load);
}

The code should work fine (at least in my little fantasy world) but I keep
getting a blank page every time I click on the image button that fires the
dlEmployeeProfi le.EditCommand.

Please help, thanks in advance.
Nov 17 '05 #1
0 1657

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

Similar topics

0
310
by: John Leacox | last post by:
I have a datalist that is nested within another datalist. I need to page the nested list. I'm binding a PagedDataSource to the list and am adding next and previous buttons to each list that needs paging. The problem is that I can't figure out a way to keep track of the current page of each list and have the current page changed on each list with a click event. I can't make a seperate click event for each list because I don't know how...
4
3081
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a label, a radiobuttonlist, etc. I'm driving myself insane trying to figure out how to get
2
3280
by: Matthew | last post by:
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.
0
1691
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the OnEditCommand event is raised, I try to do the following: 1. Find the selected datalist item in which the nested datagrid raised the event. (by calling getDataGridReference and returning the DataList's selectedIndex)
1
2559
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 datalist's itemdatabound event. Now I need to do some work in the itemdatabound event of the datagrid that is nested. I can't seem to reference it. How can I reference it so that they page knows to look for that event? How can I get to the...
2
3428
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me get over the hump here. Some of our products come in different sizes - i.e. what I call "units". Some products don't. I successfully created the first datalist (called productList) to show our products with their general
0
2224
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools from www.franson.com For some reason my code below doesnt work - the GpsFixEvent never seems to "fire" as it were.
6
1738
by: Steve Hershoff | last post by:
Hi everyone, I've got a strange one here. There are two datagrids on my page, one nested within the other. I'll refer to them as the topmost and secondary datagrids. In the topmost datagrid's OnItemDataBound() method we check for the row in which it's appropriate to add the secondary datagrid. Exactly one row in the topmost grid will contain the secondary grid.
8
10814
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList steps successfully with the following code... Control myContainer = (Control)Wizard1.FindControl("SideBarContainer"); DataList mySideBarList = (DataList)myContainer.FindControl("SideBarList");
0
8071
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
8013
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,...
0
8503
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8164
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,...
1
6017
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4039
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2482
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
0
1345
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.