473,545 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New event not firing

Hi all,

I am dynamically creating a LinkButton in my datagrid, however, the event
that I am creating for it is not firing.

I am obviously missing something? What am I missing?

Here is the code in my datagrid ItemDataBound
LinkButton MyButton = new LinkButton();
MyButton.Text = DataBinder.Eval (DI, "DFES Number").ToStri ng();
MyButton.Comman d += new CommandEventHan dler(this.Stats _Link_Click);
MyButton.Comman dName = "StatsGrid_Butt on_Click";
MyButton.Comman dArgument = DataBinder.Eval (DI, "DFES
Number").ToStri ng();
e.Item.Cells[0].Controls.Add(M yButton);
I have a Stats_Link_Clic k event, but it is not firing.

Thanks for any help.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
Nov 19 '05 #1
2 1126
Make sure to create this linkbutton and hook up the event on postback before
or during page_load. My guess is that you are creating this on initial
load, but not during postback.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"David" <da************ *****@revilloc. REMOVETHIS.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Hi all,

I am dynamically creating a LinkButton in my datagrid, however, the event
that I am creating for it is not firing.

I am obviously missing something? What am I missing?

Here is the code in my datagrid ItemDataBound
LinkButton MyButton = new LinkButton();
MyButton.Text = DataBinder.Eval (DI, "DFES Number").ToStri ng();
MyButton.Comman d += new CommandEventHan dler(this.Stats _Link_Click);
MyButton.Comman dName = "StatsGrid_Butt on_Click";
MyButton.Comman dArgument = DataBinder.Eval (DI, "DFES
Number").ToStri ng();
e.Item.Cells[0].Controls.Add(M yButton);
I have a Stats_Link_Clic k event, but it is not firing.

Thanks for any help.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

Nov 19 '05 #2
David,

Actually, I think the problem is a different one. When a control is
contained inside of another, like your button being contained inside of your
datagrid, you can't hook up an event directly to it.

Instead on post back you'll need to figure out which of the rows in the
datagrid was clicked. I have very similar sample code on my web site,
www.aboutfortunate.com where I am showing how to add a checkbox to a
datagrid and then see which checkbox was checked. The code to figure out
which button was clicked will be almost identical.

If you click the "Code Library" link at the top of my site and then use the
search box that will appear on the page to search for "Checkbox in Datagrid"
you will find the code sample you need.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OU******** ******@tk2msftn gp13.phx.gbl...
Make sure to create this linkbutton and hook up the event on postback
before or during page_load. My guess is that you are creating this on
initial load, but not during postback.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"David" <da************ *****@revilloc. REMOVETHIS.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Hi all,

I am dynamically creating a LinkButton in my datagrid, however, the event
that I am creating for it is not firing.

I am obviously missing something? What am I missing?

Here is the code in my datagrid ItemDataBound
LinkButton MyButton = new LinkButton();
MyButton.Text = DataBinder.Eval (DI, "DFES Number").ToStri ng();
MyButton.Comman d += new CommandEventHan dler(this.Stats _Link_Click);
MyButton.Comman dName = "StatsGrid_Butt on_Click";
MyButton.Comman dArgument = DataBinder.Eval (DI, "DFES
Number").ToStri ng();
e.Item.Cells[0].Controls.Add(M yButton);
I have a Stats_Link_Clic k event, but it is not firing.

Thanks for any help.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Nov 19 '05 #3

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

Similar topics

2
21977
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages on different menu forms. Details: frmTRNMenu is the main menu of the application. It uses tabbed pages to logically separate menu items. The...
13
7455
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the...
0
1677
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button. When the login is successful login page writes back javascript
3
3759
by: Brett | last post by:
I'm using a third part component in a certain app. The component has methods and events. I noticed one particular event was not firing after a while but it should have been. The problem was the "handles" part was missing. I didn't remove this that I know of. After putting this back in, the event started firing. Actually, the code inside...
1
5054
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was testing this, I noticed that the OnCurrent event wasn't firing. I went to an older version of the program and saw that it wasn't firing there...
4
4178
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it...
5
4525
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the onmouseleave / onmouseout event I've attached to my hidden drop down (in this case an <ul>), is not firing correctly. It seems that when the mouse...
6
19265
by: sjoshi | last post by:
I have a derived class OraBackup which has a method that calls stored procedure on Oracledb to get status of backup job. Now the base class publishes an event like this: public delegate void PercentEventHandler(object sender, JobCompletedEventArgs e); public event PercentEventHandler PercentCompleted; And fires it:
2
3902
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever...
1
2843
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the following code to execute. But the page load event is not firing. I tried , the same function rewriten in C#, then page load event worked absolutely fine....
0
7487
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...
0
7420
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...
0
7934
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...
1
7446
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...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
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...
1
1908
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
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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...

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.