473,749 Members | 2,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1702
You basically put a server control such as a Panel or a <div
id="divOtherCtr ls" 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.Fi ndControl("divO therCtrls"),Htm lContainerContr ol).Controls.Ad d(YourNewContro l)

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********@hotm ail.com
http://www.nathansokalski.com/

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message
news:up******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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.Ad d (New LiteralControl( "<table>"))
For each oItem in arrMyControlLis t
ph1.Controls.Ad d (New LiteralControl( "<tr><td>") )
ph1.Controls.Ad d( oItem.A)
ph1.Controls.Ad d (New LiteralControl( "</td><td>"))
ph1.Controls.Ad d( oItem.B )
ph1.Controls.Ad d (New LiteralControl( "</td></tr>"))
Next
ph1.Controls.Ad d (New LiteralControl( "</table>"))
-----------------------------------------------------
it works.

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message news:up******** ******@TK2MSFTN GP12.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
12432
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, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
0
1061
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 certain templates to be used with certain Web Server controls How would I know which web server control support which template. thanks
1
2672
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 DataList, I have a PlaceHolder control called phVariations. During the ItemDataBound event for dlProducts, I dynamically create a few DropDownLists (again, from a database) and .Add the DropDownList to the PlaceHolder control. That all works just...
4
3096
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 label, a radiobuttonlist, etc. I'm driving myself insane trying to figure out how to get
2
1334
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 controls. Example: I have custom server control that adds a rollover effect to the base Image control. Inside my ItemTemplate I would like to use it rather than base image control. How do this? Intellisense only shows me the base controls. ...
2
6964
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
1
2843
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... <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatLayout="Flow"> <ItemTemplate> <div class="Rating"> <ajaxToolkit:rating ID="SongRating" runat="server" ...
7
4489
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 event I want to do a server side function and then refresh the Page where the PlaceHolder risides. I have no problem doing the server side function, but the following 'alert' never shows up after the server side funtion. I am using the alert...
0
8996
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
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9388
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
9333
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
8256
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
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.