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

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 1038
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_author_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_author_plug>
----------------------------------------------

"Clay Beatty" <cl**@beattyhome.com> wrote in message
news:b6**************************@posting.google.c om...
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
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...
12
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! ...
0
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...
7
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 ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.