Solved

Need help on programmatically setting HeaderTemplate for DataList...

Posted on 2009-06-30
1
392 Views
Last Modified: 2013-11-05
Hi,

How do I programmatically set HeaderTemplate for DataList? For example, I want to programmatically create the "<HeaderTemplate>" tags for the DataList below (see code below) and set its value to "Product Information", e.g.,  "<HeaderTemplate><b>Product Information</b></HeaderTemplate>", during Page_Load.

Thanks a lot.

<asp:DataList 

            ID="dlProducts" CssClass="dataView" 

            Runat="server">

            <ItemTemplate>

            <h4><%#Eval("ProductName")%></h4>

            Description: <%#Eval("ProductDesc")%><br />

           Price: <%#Eval("ProductPrice")%>

            </ItemTemplate>

        </asp:DataList>

Open in new window

0
Comment
Question by:WebAppDeveloper
1 Comment
 
LVL 9

Accepted Solution

by:
tetorvik earned 500 total points
ID: 24751517
you can create a user control (say YourUserControl.ascx) containing the html <b>Product Information</b>.
then you can load this control to your datalist header template dynamically with following (for example in aspx page_load before databinding):
            dlProducts.HeaderTemplate =  LoadTemplate("YourUserControl.ascx");

Hope this helps!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now