473,666 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.Net - how do I create a varying number of UserControls?

OK, I am a .Net newbie... and I'm sure that if I spend the next two
weeks pouring through MSDN articles, I will find the answer... But...
I'm sure that this is done all the time, and so I'm sure the answer
could be found here much more quickly :)

I have a page, whose load event will execute a database query. Based
on the number of rows returned from that query, I would like
instantiate a new UserControl for each and every row. I would like to
place those user controls into a dynamically generated HTML table, and
also I would like to set the properties of each control based on the
contents of the applicable row in the result set.

Problem is, I don't have clue as to how to start this... I have
searched these news groups, and found referneces to placeholder and to
the LoadControl function... but I haven't seen a case close to the
one I described above.

The simplest code sample would be greatly appreciated.... Thank you in
afvance :)

Clay Beatty
Nov 18 '05 #1
1 1046
Why dont you bind the resultset to an asp.net datagrid - it renders as a
table and is very flexible, you can also set its output to use virtually any
control you wish as the template for it which emans you should be abel to
sue your user control. Tons of code examples around on databinding and
templates.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_auth or_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_autho r_plug>
----------------------------------------------

"Clay Beatty" <cl**@beattyhom e.com> wrote in message
news:b6******** *************** ***@posting.goo gle.com...
OK, I am a .Net newbie... and I'm sure that if I spend the next two
weeks pouring through MSDN articles, I will find the answer... But...
I'm sure that this is done all the time, and so I'm sure the answer
could be found here much more quickly :)

I have a page, whose load event will execute a database query. Based
on the number of rows returned from that query, I would like
instantiate a new UserControl for each and every row. I would like to
place those user controls into a dynamically generated HTML table, and
also I would like to set the properties of each control based on the
contents of the applicable row in the result set.

Problem is, I don't have clue as to how to start this... I have
searched these news groups, and found referneces to placeholder and to
the LoadControl function... but I haven't seen a case close to the
one I described above.

The simplest code sample would be greatly appreciated.... Thank you in
afvance :)

Clay Beatty

Nov 18 '05 #2

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

Similar topics

6
6361
by: Mark | last post by:
I've been asked to convert a pay increase spreadsheet to an intranet page. So far I've developed a page that uses a combination of ASP and Javascript to retrieve all of the required information from the HR database. The problem is that I need to be able to calculate the new salary based on an increase_amount field, as well as maintain a running total of the increase amounts. Once the amounts have been determined, I then need to submit...
12
2074
by: dima | last post by:
Hello All! Does anybody know anything about type-safe implementation of functions with varying number of arguments? I know one old solution - elipsis (stdarg,h). But it is NOT type-safe! Thanks!
0
1385
by: =?Utf-8?B?QWtzaGF5?= | last post by:
I'm adding UserControls as WebPart at runtime to a WebPartZone. This is working fine but when I add two or more UserControl instances, the UserControls are overlapping each other i.e. When I add first UserControl it gets added successfully but when I add another UserControl to the same zone, this new UserControl overlapps the first UserControl and it gives a confusing look to the user. Also, the Title area of these webparts shows at...
7
4973
by: Edwin Martinez | last post by:
Hello I have a parent form but I want to create 4 forms that will be shown in a area inside the parent form when I click to buttons. +----------------------------+ | Parent Form | | | | -------------------- | | | subform | | | | | | | | | |
0
8454
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
8363
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
8787
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
8561
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
6203
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
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.