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

how to dynamically create web controls without placeholder

i need to dynamically add a web control to a page without using placeHolder.
i'm looping through all the files in a folder and creating a table row as
string for each file. the contol is to be nested in that row as follows:

sTblRow = "<tr><td>" + sFrom + "</td><td><asp:DropDownList id=\"lstAction_"
+ filename + "\" runat=\"server\<asp:ListItem
Value=\"deliver\">Deliver</asp:ListItem><asp:ListItem
Value=\"whitelist\">Whitelist</asp:ListItem><asp:ListItem
Value=\"delete\">Delete</asp:ListItem><asp:ListItem
Value=\"blacklist\">Blacklist</asp:ListItem></asp:DropDownList></td></tr>";

the sTblRow string is then written to a literal control on the aspx page.

this doesn't work though. the control isn't recognized as a web control and
just displays as text. i can't really use a placeHolder as the table rows
themselves are dynamically created. any ideas how to pull this off?

tks


Jul 26 '06 #1
4 1419
Well, assuming that this is copied from the real code and not added
manually, this code would not work as is in any case. In the
DropDownList control the runat attribute is missing a quote. That could
cause the control to not be recognized.

"Dica" <ge*****@hotmail.comwrote in message
news:ypJxg.139927$I61.43070@clgrps13:
i need to dynamically add a web control to a page without using placeHolder.
i'm looping through all the files in a folder and creating a table row as
string for each file. the contol is to be nested in that row as follows:

sTblRow = "<tr><td>" + sFrom + "</td><td><asp:DropDownList id=\"lstAction_"
+ filename + "\" runat=\"server\<asp:ListItem
Value=\"deliver\">Deliver</asp:ListItem><asp:ListItem
Value=\"whitelist\">Whitelist</asp:ListItem><asp:ListItem
Value=\"delete\">Delete</asp:ListItem><asp:ListItem
Value=\"blacklist\">Blacklist</asp:ListItem></asp:DropDownList></td></tr>";

the sTblRow string is then written to a literal control on the aspx page.

this doesn't work though. the control isn't recognized as a web control and
just displays as text. i can't really use a placeHolder as the table rows
themselves are dynamically created. any ideas how to pull this off?

tks

Jul 26 '06 #2

"David Williams" <da**************@earthlink.netwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
Well, assuming that this is copied from the real code and not added manually, this code would not work as is in any case. In the DropDownList control the runat attribute is missing a quote. That could cause the control to not be recognized.
yeah, that's a typo here only. there is an end quote in my code.
"Dica" <ge*****@hotmail.comwrote in message news:ypJxg.139927$I61.43070@clgrps13:
i need to dynamically add a web control to a page without using placeHolder.
i'm looping through all the files in a folder and creating a table row as
string for each file. the contol is to be nested in that row as follows:

sTblRow = "<tr><td>" + sFrom + "</td><td><asp:DropDownList id=\"lstAction_"
+ filename + "\" runat=\"server\<asp:ListItem
Value=\"deliver\">Deliver</asp:ListItem><asp:ListItem
Value=\"whitelist\">Whitelist</asp:ListItem><asp:ListItem
Value=\"delete\">Delete</asp:ListItem><asp:ListItem
Value=\"blacklist\">Blacklist</asp:ListItem></asp:DropDownList></td></tr>";

the sTblRow string is then written to a literal control on the aspx page.

this doesn't work though. the control isn't recognized as a web control and
just displays as text. i can't really use a placeHolder as the table rows
themselves are dynamically created. any ideas how to pull this off?

tks
Jul 26 '06 #3
You could have a server side table control. This way you'll be able to use
its programming model and add rows objects to this table. In a cell you'll
be able to add a dropdowncontrol as a server side control etc...

Here the problem is likely that you render some text to the browser (i.e.
you'll see asp:DropDownlist client side).

You could also use a Repeater or perhaps a DataList/GridView etc...

--
Patrice

"Dica" <ge*****@hotmail.coma écrit dans le message de news:
ypJxg.139927$I61.43070@clgrps13...
>i need to dynamically add a web control to a page without using
placeHolder. i'm looping through all the files in a folder and creating a
table row as string for each file. the contol is to be nested in that row
as follows:

sTblRow = "<tr><td>" + sFrom + "</td><td><asp:DropDownList
id=\"lstAction_" + filename + "\" runat=\"server\<asp:ListItem
Value=\"deliver\">Deliver</asp:ListItem><asp:ListItem
Value=\"whitelist\">Whitelist</asp:ListItem><asp:ListItem
Value=\"delete\">Delete</asp:ListItem><asp:ListItem
Value=\"blacklist\">Blacklist</asp:ListItem></asp:DropDownList></td></tr>";

the sTblRow string is then written to a literal control on the aspx page.

this doesn't work though. the control isn't recognized as a web control
and just displays as text. i can't really use a placeHolder as the table
rows themselves are dynamically created. any ideas how to pull this off?

tks


Jul 26 '06 #4

"Patrice" <sc****@chez.comwrote in message
news:ex**************@TK2MSFTNGP02.phx.gbl...
You could have a server side table control. This way you'll be able to use
its programming model and add rows objects to this table. In a cell you'll
be able to add a dropdowncontrol as a server side control etc...
good suggestions. tks.
>
Here the problem is likely that you render some text to the browser (i.e.
you'll see asp:DropDownlist client side).

You could also use a Repeater or perhaps a DataList/GridView etc...

--
Patrice

"Dica" <ge*****@hotmail.coma écrit dans le message de news:
ypJxg.139927$I61.43070@clgrps13...
>>i need to dynamically add a web control to a page without using
placeHolder. i'm looping through all the files in a folder and creating a
table row as string for each file. the contol is to be nested in that row
as follows:

sTblRow = "<tr><td>" + sFrom + "</td><td><asp:DropDownList
id=\"lstAction_" + filename + "\" runat=\"server\<asp:ListItem
Value=\"deliver\">Deliver</asp:ListItem><asp:ListItem
Value=\"whitelist\">Whitelist</asp:ListItem><asp:ListItem
Value=\"delete\">Delete</asp:ListItem><asp:ListItem
Value=\"blacklist\">Blacklist</asp:ListItem></asp:DropDownList></td></tr>";

the sTblRow string is then written to a literal control on the aspx page.

this doesn't work though. the control isn't recognized as a web control
and just displays as text. i can't really use a placeHolder as the table
rows themselves are dynamically created. any ideas how to pull this off?

tks



Jul 27 '06 #5

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

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
12
by: Jerad Rose | last post by:
I searched for a while trying to find the answer to this, but to no avail. I am trying to find the best way (or any way) to dynamically show and hide groups of TR's. For example, I have a...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
2
by: A.Wussow | last post by:
Hi Everybody, i want to load dynamically content from some user controls (with forms, or some data-controls) using atlas. So i use an UpdatePanel for loading the user control into a placeholder....
3
by: Mark Denardo | last post by:
I'm trying to dynamically create and add controls to a web page: Label obj1 = new Label(); DropDownList obj2 = new DropDownList(); Controls.Add(obj1); Controls.Add(obj2); But I get the...
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
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
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...
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
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,...
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.