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

Dynamicly adding controls after Page_Load event

GS
Hi,

I dynamicly add custom control in SelectedIndexChanged even of GridView which is firing after Page_Load. My control is not being rendered to page becouse of that (I assume). How to avoid this situation? Sample below

protected void dgrCompanies_SelectedIndexChanged(object sender, EventArgs e)
{
GoogleControl MyGoogleControl = new GoogleControl ();
PlaceHolderForMap.Controls.Add(MyGoogleControl);
}

Feb 14 '06 #1
4 2084

No, your conrol will be rendered after PreRender which happens after this event.

Have you set your control to visible
Have you positioned your control
Have you checked the Z-Order of the control
Is the PlaceHolder visible.
Have you checked that this should appear with no data in it for example ?
--
Terry Burns
http://TrainingOn.net

"GS" <no****@nowhere.com> wrote in message news:Ob**************@TK2MSFTNGP12.phx.gbl...
Hi,

I dynamicly add custom control in SelectedIndexChanged even of GridView which is firing after Page_Load. My control is not being rendered to page becouse of that (I assume). How to avoid this situation? Sample below

protected void dgrCompanies_SelectedIndexChanged(object sender, EventArgs e)
{
GoogleControl MyGoogleControl = new GoogleControl ();
PlaceHolderForMap.Controls.Add(MyGoogleControl);
}

Feb 14 '06 #2
GS
Control is not positioned on webpage at all. My understanding that I can load it programmatically without putting it on webpage (one reference is set at <%@ reference
Placeholder is visible. Code below works fine for TextBox control for example but not for custom control.

"Terry Burns" <me@mine.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...

No, your conrol will be rendered after PreRender which happens after this event.

Have you set your control to visible
Have you positioned your control
Have you checked the Z-Order of the control
Is the PlaceHolder visible.
Have you checked that this should appear with no data in it for example ?
--
Terry Burns
http://TrainingOn.net

"GS" <no****@nowhere.com> wrote in message news:Ob**************@TK2MSFTNGP12.phx.gbl...
Hi,

I dynamicly add custom control in SelectedIndexChanged even of GridView which is firing after Page_Load. My control is not being rendered to page becouse of that (I assume). How to avoid this situation? Sample below

protected void dgrCompanies_SelectedIndexChanged(object sender, EventArgs e)
{
GoogleControl MyGoogleControl = new GoogleControl ();
PlaceHolderForMap.Controls.Add(MyGoogleControl);
}

Feb 14 '06 #3
Hold on, your original post asked.
My control is not being rendered to page becouse of that (I assume).


So what is it you think isnt happening that you think should ?

--
Terry Burns
http://TrainingOn.net

"GS" <no****@nowhere.com> wrote in message news:OG*************@TK2MSFTNGP11.phx.gbl...
Control is not positioned on webpage at all. My understanding that I can load it programmatically without putting it on webpage (one reference is set at <%@ reference
Placeholder is visible. Code below works fine for TextBox control for example but not for custom control.

"Terry Burns" <me@mine.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...

No, your conrol will be rendered after PreRender which happens after this event.

Have you set your control to visible
Have you positioned your control
Have you checked the Z-Order of the control
Is the PlaceHolder visible.
Have you checked that this should appear with no data in it for example ?
--
Terry Burns
http://TrainingOn.net

"GS" <no****@nowhere.com> wrote in message news:Ob**************@TK2MSFTNGP12.phx.gbl...
Hi,

I dynamicly add custom control in SelectedIndexChanged even of GridView which is firing after Page_Load. My control is not being rendered to page becouse of that (I assume). How to avoid this situation? Sample below

protected void dgrCompanies_SelectedIndexChanged(object sender, EventArgs e)
{
GoogleControl MyGoogleControl = new GoogleControl ();
PlaceHolderForMap.Controls.Add(MyGoogleControl);
}

Feb 14 '06 #4
Hi,

Dynamical controls would need to be added on every request. Control
instances aren't stored anywehere, and as you create them initially in code,
you are also responsible for creating them on postback (subsequently as long
as control is "in action")

FYI: http://aspnet.4guysfromrolla.com/articles/092904-1.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"GS" <no****@nowhere.com> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
Hi,

I dynamicly add custom control in SelectedIndexChanged even of GridView
which is firing after Page_Load. My control is not being rendered to page
becouse of that (I assume). How to avoid this situation? Sample below

protected void dgrCompanies_SelectedIndexChanged(object sender, EventArgs e)
{
GoogleControl MyGoogleControl = new GoogleControl ();
PlaceHolderForMap.Controls.Add(MyGoogleControl);
}
Feb 15 '06 #5

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
by: Henke | last post by:
Hi I have a aspx-page with a panel-control. On this panel control I add user controls dynamicly with LoadControl and panel.Controls.Add(myControl). On some of the dynamicly added user controls I...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
2
by: Sam Kuehn | last post by:
There has been a lot of articles on how to load user controls at runtime in the Init() method. UserControl myControl = (UserControl)LoadControl(stringControl); I add the control in the Init()...
2
by: Ben Amada | last post by:
I'm a little confused about in what Event should I add dynamic controls and in what Event should I retrieve the value of a dynamic control on postback. I've found that adding dynamic controls in...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
5
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
0
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...
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,...

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.