Dynamically loading user control to a gridview - Button in the user control doesn't fire event


I know there are many posts about loading user control dynamically and events which not fire. I tried  everything suggested but nothing helped.

The difference in my example is that I am loading the user control into a specific line in a grid view after the user clicked on a button.

So, the containing object in this case is DataControlFieldCell but it is a difference one on every click of the user.

I tried to to set the ID of the user control on the page load of the control (this.ID = "MyControl1";) and I am loading the control on post back in the page_load of the parent page to the same cell (I am saving the cell it was last loaded to), in addition to adding it on the button_click event.


Here is some code:


from the parent page page_load: 

        if (!Page.IsPostBack)

                if (cell != null)
                    followupControl = LoadControl("MyControl.ascx");




from the parent page LinkButton_Click:


protected void btnFollowUp_Click(object sender, EventArgs e)
LinkButton btn = (LinkButton)sender;
cell = (DataControlFieldCell)btn.Parent;
followupControl = LoadControl("MyControl.ascx");





from the user control : 

protected void Page_Load(object sender, EventArgs e)

            this.ID = "MyControl1";






Students can save on textbooks
7/18/2007 5:17:36 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 26
Get it on Google Play
Get it on Apple App Store

You would have to handle user control's event.

from Villa El Salvador for world!
7/19/2007 5:22:00 AM

 The problem is that the click doesn't fire the Button_click event.

Anyway, I did it in another way (and much simpler one). I am using the "editItemTemplate" to show the user control...

Thank you


Students can save on textbooks
7/19/2007 1:45:05 PM

Similar Artilces:

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

Label control's text doesn't appear to be set (in the page which has a user control )when trying to update the text property in the FormView's ItemUpdated event
Hi There,I have a user control which hosts a formview control, gridview control and a label control. The grid view is usedto show rows in the DB and when clicked to edit each row, a form view opens up in edit mode with that particular row info. So I have nothing in the item template.My first question is..is it mandatory to have smth in the itemtemplate of the form view.I have controls in edititemtemplate and insertitemtemplate.When a particular row is edited, I would like to show a status msg showing that the row has been updated.For this, I use the ItemUpdated event of the formview and try ...

User Control controls not created when dynamically creating user control
  Have created a user control for displaying and editing a dynamically number of values. The user control contains two labels and an edit box. When dynamically loading the user control I get an error when the control itself tries to change setting on the fields within the user control.   Why doesnt this work? It works okay if I dont load it dynamically but create a user-control-instance in the aspx-page but thats no solution.   Thankyou!     Here is my code:   ucDataValue.ascx   <%@ Control Language="C#" AutoEventWireup="true&...

dynamically load user control from another user control
Is it possible to dynamically load a user control from another user control?  I have an aspx page where I have declaratively included a user control.  Now, within that user control I want to dynamically load another usercontrol onto the page based on some business logic.  Does this even make sense? So, here's the scenario:aspx page:<%@ Register TagPrefix="header" TagName="links" Src="~/usercontrols/toplink.ascx" %><asp:Content ID="ContentBody" ContentPlaceHolderID="cphBody" runat="Server">  ...

User Controls
Hi,I'll make this senario somewhat generic. I have an ASPX Page, within the aspx page I have two web user controls. "uc1" contains a datalist, on uc2 I have a form with a submit button. I want to fire the databind of the datalist in uc1 from the submit button on uc2, how can I do this?Thank you, New Orleans Hornets Season Ticket Holder! "uc2" should raise an event that your Page can handle. Then, in the Page handler for this event, you can call the DataBind method of "uc1".Thanks, EdMicrosoft MVP - ASP/ASP.NET  Is this where delegates come into...

dynamically load user controls within a user control problem
I am dynamically loading a set of user controls from within a user control (static user control). I add my user controls, at runtime, to the controls collection of a Panel control that is on my static user control. I reload my dynamic user controls each time my static user control runs its Page_Load event. Everything works fine, but my dynamic user control button events do not fire. Any help appreciated.   Regards, Paul. Hi,  how and where do you add the event handler to your user control button? I have a page (aspx) that has a user control (static) on it...

Dynamically added user controls.. Restoring user control events ...
Hello, i ve made a simple aspx page to focus on the problem..In the aspx page i have a button that when it is pressed a user control is added dynamically, So if you press the button twice , two user controls will be added..Here is how i implement it :When a user control is added ,i add it to an arraylist (which contains all the  user controls that have been inserted to the page ) and this array list is then added to the session.So when the page is loaded ,i retrieve that arraylist back from the session i iterate through it ,and i enter again to the page all the previous added user contr...

Dynamic user control's onclick event won't fire
I'm dynamically creating several user controls that get loaded dynamically into a placeholder based on which linkbutton a user clicks, however my linkbutton onclick events never fire off.  I've tried initializing them in the Page_Init, Page_Load, & On_Init however none seemed to work.  If it helps, my placeholder control is located on my masterpage (called "phMenuContent") and I'm using ajax.  Here's my code so far: My user control page: ---------------------------------------------------------------------------------...

Event doesn't fire in user control.
Hello, I have an image button in a user control and I'm trying to detect it's click event in the page that contains the control. The event fires ok, and the code gets to the 'OnImageClicked' method (highlighted -->) in the user control, but the value for the delegate 'ImageClicked' is always null. Anyone any ideas? Thanks. public class Submit : System.Web.UI.UserControl { protected System.Web.UI.WebControls.ImageButton imgbtnSubmit; public delegate void ImageClickedHandler(object sender, EventArgs e); public event ImageClickedHandler ImageClicked; pro...

Loading a dynamic user control on main page from current user control
Hi,  Please help,  I've posted this a week ago and never got a response.  I'm still stuck on the same problem.I have a panel that I load user Control in no problem.  The problemarrises when I do a post back on one of these user controls.  I havebutton it does a click event.  In this click event I will do somedatabase updates, then I will use reflection to call a method in theparent (this.page) to load the new user control.  Its at this pointafter it loads the new user control that it throws the error "Thecontrol must be placed inside a form tag...

Email user control don't work if have other User Control
Well I'm totally confused and I think I'm missing anything. I have a web page with forms to send email. This is great and is fuctional. The problem is when I add a User Control to the page (for example a Header) ... the email stops working, I press the send button and nothing heapen. I tried to turn around the problem and I created a User Control with the emails forms. I add these user controls to a empty page (new page) .... and great it works .... but when other User control ... again .. it stops working. Anyone can help me ... the code in my aspx (new aspx) is the following ...

User Controls won't see each other user controls in same namespace
I've browse alot for this error but I can't find any answer to my problem. Please help !!!!I am creating a PageMenu user control which contains several PageMenuItems. Both compile without any problem and I would like PageMenuItems to call PageMenu's click event when a click event is received. I am trying to cast PageMenuItems's Parent property to access PageMenu. In the namespace I created, I PageMenuItems won't see PageMenu. The only way I could make PageMenuItems see PageMenu was by registering the control in the aspx file.I also realized that both PageMenu and PageMenuItems would not see ...

User Control in a User Control
I have a first user control that contain a second user control. If I cahe the first user control can I still dynamically control the second one or it is cached with the first one therefore can not control it anymore? Thanks When your first control is cached, its rendered out and its output is stored in the cache. On every request to the page containing your control that can satisfy it from cache, the output will just simply be inserted - your first control will never be instantiated or run in that case, so the second one wont be either. Hope this helps,Mike VolodarskyProgram Manager...

user control to user control
I have an aspx page that have a "Register" directive to two usercontrol called rptMaster.ascx and rptDetail.ascx. I'm trying to set up a Master-Detail relationship and wish for the rptMaster.ascx to trigger and event from a dropdownlist and for the rptDetail to be listening for DropDownList event. I believe I have gotten the events part okay with help from this articel http://codeproject.com/aspnet/Page_UserControl.asp but my declaration for a private statement to my rptMaster class is producing an error. I'm using beta 2 of asp.net and I 'm having trouble getting a reference TO ...

User Controls in User Controls?
I have the follow set up and it is throwing an error "Unhandled error loading module" ... is there some trick to this that I don't know?I have a project A that uses controls from project B (project B is just a project with all my user controls used through out other modules).  project A uses user control 1 from project B with out any issues at all - great.  But then I wanted to add user control 2 to user control 1 and that is when I get my error.  In fact I don't even have the user control 2 in user control 1, just when I put the register part into user control 1 is when it al...

Web resources about - Dynamically loading user control to a gridview - Button in the user control doesn't fire event - asp.net.presentation-controls

iPhone 5 A6 chip to dynamically up-clock up to 1.3GHz (and downclock too)?
Interesting video from our friends at TLDToday: If this is not just a Geekbench app glitch, it could indicate why that A6 processor is so 2X ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

iPhone 5 Lightning port dynamically reassigns pins
... of Apple's Lightning USB cable shows that the pins on the plug aren't arranged symmetrically, suggesting that the Lightning port can dynamically ...

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...

A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 1/18/2016 11:44:31 PM