473,387 Members | 1,534 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.

add server controls to the templates for the DataList control.

how do I load controls to the templates for the DataList control.

<asp:datalist id="dl1" runat="server" >
<ItemTemplate>

" how to load control(s) here ????"

</ItemTemplate>
</asp:datalist>
Mar 18 '06 #1
3 1682
You basically put a server control such as a Panel or a <div
id="divOtherCtrls" runat="server"></div> (remember to declare the div or
other HTML control if you use one) in the <ItemTemplate></ItemTemplate>
tags. Then, to add the controls, use the Add() method of the Panel or div's
Controls property. To do this, you would use code such as:

CType(e.Item.FindControl("divOtherCtrls"),HtmlCont ainerControl).Controls.Add(YourNewControl)

This code must be placed inside either the ItemCreated or ItemDataBound
events, otherwise the e object will not be available. Feel free to ask if
you have any trouble.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
how do I load controls to the templates for the DataList control.

<asp:datalist id="dl1" runat="server" >
<ItemTemplate>

" how to load control(s) here ????"

</ItemTemplate>
</asp:datalist>

Mar 19 '06 #2
If you mean populating Templates dynamically in code, you could also utilize
ITemplate interface
http://msdn2.microsoft.com/en-us/lib...itemplate.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
news:up**************@TK2MSFTNGP12.phx.gbl...
how do I load controls to the templates for the DataList control.

<asp:datalist id="dl1" runat="server" >
<ItemTemplate>

" how to load control(s) here ????"

</ItemTemplate>
</asp:datalist>

Mar 19 '06 #3
Although I appreciate your offer to help, I couldn't understand/implement either of the suggested solutions.

Since I couldn't get the datalist to work, I found an alternate approach to organize the display of dynamic controls into a page.
To keep it simple, I used a placeholder(ph1) in the html and I did this in the page_load code:

------------------------------------------------------
ph1.Controls.Add (New LiteralControl("<table>"))
For each oItem in arrMyControlList
ph1.Controls.Add (New LiteralControl("<tr><td>"))
ph1.Controls.Add( oItem.A)
ph1.Controls.Add (New LiteralControl("</td><td>"))
ph1.Controls.Add( oItem.B )
ph1.Controls.Add (New LiteralControl("</td></tr>"))
Next
ph1.Controls.Add (New LiteralControl("</table>"))
-----------------------------------------------------
it works.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message news:up**************@TK2MSFTNGP12.phx.gbl...
how do I load controls to the templates for the DataList control.

<asp:datalist id="dl1" runat="server" >
<ItemTemplate>

" how to load control(s) here ????"

</ItemTemplate>
</asp:datalist>

Mar 19 '06 #4

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

Similar topics

12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
0
by: | last post by:
hi, I came a cross different type of templates in .net such as itemTemplate or HeaderTemplate. Can I use any of those template with all server controls (exa Datagrid or Datalist) ? or there are...
1
by: Scott Schluer | last post by:
Hello, I've got myself a small problem and I'm hoping someone can help. I have a DataList called dlProducts (displays products from a database). Within the <ItemTemplate> container of the...
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
2
by: Charlie | last post by:
Hi: When using templated columns in DataList, ASP.net server controls can be inserted. Rather than using the base ASP.net server controls, I would like to use one of my own custom server...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
1
by: lamarant | last post by:
Hi...I'm trying to use the Rating Control in the Ajax Toolkit in a datalist. I have the control showing up in the list, with the logged in users current rating for each item in the list showing... ...
7
by: Peter | last post by:
I have a HoverMenuExtender which contains an asp:PlaceHolder, this place holder has a User Control and this control contrains a Button. The problem I am having is after the button fires the click...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.