Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
David Lozzi #1
Create User Controls dynamically
Howdy,
I have a user control that needs to be displayed X amount of times on one
page. How is this done? I was thinking of putting it into a datagrid, which
would work, but is there a better way?
Thanks!
--
David Lozzi
Web Applications Developer
[email]dlozzi@(remove-this)delphi-ts.com[/email]
David Lozzi Guest
-
Dynamically created user controls
In ASP.Net, I am working with some in-house software that dynamically creates a form based on rows in a database table. For example, most pages... -
Dynamically create controls with non-hierarchical IDs
You could add a Name attribute to the control and use GetElementsByName to find it. Dale "Simon Wallis"... -
dynamically adding user controls
I have a web form that has a button called "Add Blank Row". Every time this button is pressed a new "blank row" user control should be added to the... -
Dynamically create controls from a network directory tree
I'm trying to create a search page with msIndex service and i want the user to be able to select the directories they would like to search within.... -
How do I dynamically create user controls?
Thanks for any help...! My error is: Object reference not set to an instance of an object. Here's the setup: I have made a user control... -
Steven Cheng[MSFT] #2
RE: Create User Controls dynamically
Hi David,
Welcome to ASPNET newsgroup.
As for dynamically creating UserControl on asp.net web page. In addition to
using Template DAtaBound control (as DataGrid, Repeater....), we can also
use Page.LoadControl to load control instance and add them into a certain
container control on the page. For example:
==================
private void Page_Load(object sender, System.EventArgs e)
{
..........
for(int i=0;i<1000;i++)
{
Control ctrl = Page.LoadControl("~/uc/MyUsercontrol.ascx");
ctrl.ID = "myuc_" +i;
MyPanel.Controls.Add(ctrl);
}
}
BTW, dynamically loading lots of usercontrols and adding into page's
control structure will cause performance issue especially when the
usercontrol is not simple one.
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "David Lozzi" <DavidLozzi@nospam.nospam>
| Subject: Create User Controls dynamically
| Date: Thu, 13 Oct 2005 01:37:16 -0400
| Lines: 16
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#qGmvg7zFHA.908@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5788
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| Howdy,
|
| I have a user control that needs to be displayed X amount of times on one
| page. How is this done? I was thinking of putting it into a datagrid,
which
| would work, but is there a better way?
|
| Thanks!
|
| --
| David Lozzi
| Web Applications Developer
| [email]dlozzi@(remove-this)delphi-ts.com[/email]
|
|
|
|
|
Steven Cheng[MSFT] Guest
-
Steven Cheng[MSFT] #3
RE: Create User Controls dynamically
Hi David,
Have you got any further progress on this issue. or does the suggestions in
my last reply helps a little? If there're anything else we can help, please
feel free to post here. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 178280068
| References: <#qGmvg7zFHA.908@tk2msftngp13.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: [email]stcheng@online.microsoft.com[/email] (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Thu, 13 Oct 2005 09:55:44 GMT
| Subject: RE: Create User Controls dynamically
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| Message-ID: <zo5RVx9zFHA.2352@TK2MSFTNGXA01.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| Lines: 53
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5789
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi David,
|
| Welcome to ASPNET newsgroup.
| As for dynamically creating UserControl on asp.net web page. In addition
to
| using Template DAtaBound control (as DataGrid, Repeater....), we can also
| use Page.LoadControl to load control instance and add them into a certain
| container control on the page. For example:
|
| ==================
| private void Page_Load(object sender, System.EventArgs e)
| {
| .........
| for(int i=0;i<1000;i++)
| {
| Control ctrl = Page.LoadControl("~/uc/MyUsercontrol.ascx");
| ctrl.ID = "myuc_" +i;
| MyPanel.Controls.Add(ctrl);
| }
| }
|
|
| BTW, dynamically loading lots of usercontrols and adding into page's
| control structure will cause performance issue especially when the
| usercontrol is not simple one.
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! [url]www.microsoft.com/security[/url]
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
| --------------------
| | From: "David Lozzi" <DavidLozzi@nospam.nospam>
| | Subject: Create User Controls dynamically
| | Date: Thu, 13 Oct 2005 01:37:16 -0400
| | Lines: 16
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-RFC2646: Format=Flowed; Original
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | Message-ID: <#qGmvg7zFHA.908@tk2msftngp13.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.comcast.net 24.63.42.200
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5788
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| |
| | Howdy,
| |
| | I have a user control that needs to be displayed X amount of times on
one
| | page. How is this done? I was thinking of putting it into a datagrid,
| which
| | would work, but is there a better way?
| |
| | Thanks!
| |
| | --
| | David Lozzi
| | Web Applications Developer
| | [email]dlozzi@(remove-this)delphi-ts.com[/email]
| |
| |
| |
| |
| |
|
|
Steven Cheng[MSFT] Guest



Reply With Quote

