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

How do I put a user control into a table?

I have a user control that create a product thumbnail and details. I am
working on aother user control that I will pass some variables like # of
columns and rows to display these thumbnails. I'm having trouble dynamicly
adding a new thumbnail control to my table.

Dim newCell As New TableCell
Dim newRow As New TableRow
Dim productThumb As New htmlBlock_ProductThumb ' This is my
usercontrol

newCell.Controls.Add(productThumb) ' Not
sure how to add it to the table cell
newRow.Cells.Add(newCell)

FeaturedProducts.Rows.Add(newRow)
Nov 17 '05 #1
2 1355
Robin,

When you load a user control it's slightly different than creating a dynamic
control.

newCell.Controls.Add(LoadControl([Path to your user control as String])

And you won't need to create the user control before this so delete the
line:

Dim productThumb As New htmlBlock_ProductThumb ' This is my usercontrol

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Robin Bonin" <ro***@guavatools.com> wrote in message
news:3F********************@eatel.net...
I have a user control that create a product thumbnail and details. I am
working on aother user control that I will pass some variables like # of
columns and rows to display these thumbnails. I'm having trouble dynamicly
adding a new thumbnail control to my table.

Dim newCell As New TableCell
Dim newRow As New TableRow
Dim productThumb As New htmlBlock_ProductThumb ' This is my
usercontrol

newCell.Controls.Add(productThumb) ' Not sure how to add it to the table cell
newRow.Cells.Add(newCell)

FeaturedProducts.Rows.Add(newRow)

Nov 17 '05 #2
Found the answer to my question.
for reference...

Dim newCell As New TableCell
Dim newRow As New TableRow
Dim productThumb As New Control

productThumb =
LoadControl("../userControls/htmlBlock_ProductThumb.ascx")
CType(productThumb, htmlBlock_ProductThumb).itemSku = "1001A"
newCell.Controls.Add(productThumb)

newRow.Cells.Add(newCell)
FeaturedProducts.Rows.Add(newRow)
"Robin Bonin" <ro***@guavatools.com> wrote in message
news:55********************@eatel.net...
This worked great, I just have one problem.
I need to pass atleast one paramater to this control for the item ID to be
dsiplayed.

I declared the control as follows.
productThumb = LoadControl("../userControls/htmlBlock_ProductThumb.ascx")

but the public properties are not exposed though the productThumb control. I tried passing a variable
through the querry string but I got an error. control needs to end with a
.ascx.

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Robin,

When you load a user control it's slightly different than creating a

dynamic
control.

newCell.Controls.Add(LoadControl([Path to your user control as String])

And you won't need to create the user control before this so delete the
line:

Dim productThumb As New htmlBlock_ProductThumb ' This is my usercontrol

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Robin Bonin" <ro***@guavatools.com> wrote in message
news:3F********************@eatel.net...
I have a user control that create a product thumbnail and details. I am working on aother user control that I will pass some variables like # of columns and rows to display these thumbnails. I'm having trouble dynamicly adding a new thumbnail control to my table.

Dim newCell As New TableCell
Dim newRow As New TableRow
Dim productThumb As New htmlBlock_ProductThumb ' This is my
usercontrol

newCell.Controls.Add(productThumb)

' Not
sure how to add it to the table cell
newRow.Cells.Add(newCell)

FeaturedProducts.Rows.Add(newRow)



Nov 17 '05 #3

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

Similar topics

0
by: Jason | last post by:
I am pretty new to C# so bare with me... The design of my website utilizes tables on every page that look almost identical, save the data they are displaying. I have written the code to create...
0
by: fernandezr | last post by:
I've got a user control which I reference twice on the same page. On the first instance of the control I need to change the skin of the table and it's textboxes to use specific skinids defined in...
0
by: fernandezr | last post by:
I've got a user control,ucAddress.ascx, which I reference twice on the same page. On the first instance of the control I need to change the skin of the table and it's textboxes to use specific...
0
by: noname | last post by:
i have a few user controls that need a "visible" property. one example is an error box. the error box's visible property would only be set in the event of an error, of course. i've come up with...
11
by: trinitypete | last post by:
Hi all, I have a user control that uses control literal to build a heading with a link, and a div containing links below. As the link heading is hit, I want to change the style of the div,...
1
by: Ben | last post by:
Hi, I would like to use web user contols for header and footer controls. The problem I'm having is that we're using tables for layout. (thanks for any pro css solutions, but thats' a different...
0
by: clintonG | last post by:
I applied aspnet_regsql to SQL2K which was working fine throughout Beta 2 development. After installing Visual Studio and SQL Express RTM my application has blown up. Logging in to the application...
2
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.