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

  • Thread starter Thread starter Clay Beatty
  • Start date Start date
C

Clay Beatty

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
 
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>
 
Back
Top