473,802 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Usercontrol not rendered in table

I am programmaticall y populating a asp.net table control with my usercontrol
(PictureBox.asc x) which is basically an assortment of an imagebutton, Label
and a Linkbutton. Now while debugging the application i can see that the
control is being initialized properly (by setting the imgurl and text values
from the db), but for some reason the usercontrol does not show up in the
table.

Here is the code for the Page: (test.aspx)
//I am calling the ArrangePictures () function on the click event of a button
which basically starts to load a list of usercontrols

/////////////////////////////////////////////////////////////////////

private void ArrangePictures ()

{

ArrayList Pics = LoadPictures();

TableRow r = new TableRow();

TableCell c;

foreach (object P in Pics)

{

c = new TableCell();

//this is where i am adding the control

//it does not throw any errors but instead

//spits out an empty cell

c.Controls.Add( ((PictureBox)P) );

r.Cells.Add(c);

if (r.Cells.Count == 3)

{

tblPictures.Row s.Add(r);

r = new TableRow();

}//if - Pics

}//foreach

if (r.Cells.Count == 2)

{

c = new TableCell();

c.ColumnSpan = 2;

r.Cells.Add(c);

tblPictures.Row s.Add(r);

}

else

{

c = new TableCell();

c.ColumnSpan = 2;

r.Cells.Add(c);

tblPictures.Row s.Add(r);

}

}//Arrange pictures

////////////////////////////////////////////////////////////////////////////////////

private ArrayList LoadPictures()

{

OleDbDataReader rdrImages = getPictureData( );

ArrayList Pictures = new ArrayList();

PictureBox Picture;

if (rdrImages.Read ())

{//Skip first file - will be used in header

while (rdrImages.Read ())

{

Picture = new PictureBox();

Picture.Picture .ImageUrl = Convert.ToStrin g(rdrImages.Get Value(2));

Picture.Picture .AlternateText = Convert.ToStrin g(rdrImages.Get Value(1));

Picture.TextCap tion.Text = Convert.ToStrin g(rdrImages.Get Value(1));

Pictures.Add(Pi cture);

}//while

}//if

if ((Pictures.Coun t < 9) && (Session["UserId"] == Session["ID"]))

{//add upload picture control if user is logged into their account

Picture = new PictureBox();

Picture.TextCap tion.Text = "Add a new picture.";

Picture.Picture .ImageUrl = Request.Applica tionPath + "/images/add.jpg";

Picture.Picture .AlternateText = "Add a new picture.";

Pictures.Add(Pi cture);

}//if

return Pictures;

}//LoadPictures


Code for the user Control (PictureBox.asc x):
private ImageButton _Picture;

private Label _Caption;

public ImageButton Picture

{

get

{

_Picture.Height = Unit.Pixel(80);

_Picture.Width = Unit.Pixel(80);

return _Picture;

}

set

{

_Picture = value;

}

}

public Label TextCaption

{

get

{

return _Caption;

}

set

{

_Caption = value;

}

}

public PictureBox()

{

this.TextCaptio n = new Label();

this.Picture = new ImageButton();

}

private void Page_Load(objec t sender, System.EventArg s e)

{

// Put user code to initialize the page here

lblCaption = this.TextCaptio n;

ibtnPicture = this.Picture;

}


Also, how would i be able to add onclick events for these dynamically loaded
controls. (ex. for ImageButton)
Jul 21 '05 #1
0 930

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

Similar topics

1
1417
by: Anon | last post by:
I am programmatically populating a asp.net table control with my usercontrol (PictureBox.ascx) which is basically an assortment of an imagebutton, Label and a Linkbutton. Now while debugging the application i can see that the control is being initialized properly (by setting the imgurl and text values from the db), but for some reason the usercontrol does not show up in the table. Here is the code for the Page: (test.aspx)
0
882
by: Anon | last post by:
I am programmatically populating an asp.net table control with my usercontrol (PictureBox.ascx) which is basically an assortment of an imagebutton, Label and a Linkbutton. Now while debugging the application i can see that the control is being initialized properly (by setting the imgurl and text values from the db, both of these are Image and label properties of the page respectively. i am using these properties to set the actual image and...
0
883
by: Anon | last post by:
I am programmatically populating a asp.net table control with my usercontrol (PictureBox.ascx) which is basically an assortment of an imagebutton, Label and a Linkbutton. Now while debugging the application i can see that the control is being initialized properly (by setting the imgurl and text values from the db), but for some reason the usercontrol does not show up in the table. Here is the code for the Page: (test.aspx)
1
1130
by: SlimFlem | last post by:
I hope this makes sense. Here is what I am attempting. I have an inital generic aspx page that has one custom tag: <web:site id=webSite runat=server/> When this control evaluates, it will return a small amount of Html with another custom control tag inside this html. For example:
0
9699
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
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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
10285
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,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
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...
2
3792
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.