473,472 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem with template file for datalist

I have a web page with a datalist in it that binds to a datatable. Within
the template I call a function to process one of fields and return the data.
This worked perfectly until I moved the template into a separate file and
specified DataList1.ItemTemplate = Page.LoadTemplate("template.ascx") in
code behind. Now I get the error: Name 'MyFunction' is not declared. If I
removed MyFunction from the template file it displays the page properly.

Example (works when the template is part of the web page but not as a
separate file):
<%# MyFunction(DataBinder.Eval(Container, "DataItem.MyField")) %>
Anyone know what the problem is?
Nov 18 '05 #1
3 1050
Greg,

When you're using a code-behind file "MyFunction" will have to be declared
as a public function in the code-behind file.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Greg" <no****@nospam.com> wrote in message
news:Of*************@TK2MSFTNGP11.phx.gbl...
I have a web page with a datalist in it that binds to a datatable. Within
the template I call a function to process one of fields and return the data. This worked perfectly until I moved the template into a separate file and
specified DataList1.ItemTemplate = Page.LoadTemplate("template.ascx") in
code behind. Now I get the error: Name 'MyFunction' is not declared. If I removed MyFunction from the template file it displays the page properly.

Example (works when the template is part of the web page but not as a
separate file):
<%# MyFunction(DataBinder.Eval(Container, "DataItem.MyField")) %>
Anyone know what the problem is?

Nov 18 '05 #2
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
Greg,

When you're using a code-behind file "MyFunction" will have to be declared
as a public function in the code-behind file.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer


Tried that already -- same error.
Nov 18 '05 #3

"Greg" <no****@nospam.com> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...

Tried that already -- same error.


I figured it out. What I needed to do was change it from just MyFunction to
MyAssemblyName.MyClass.MyFunction. I also needed to added Shared to
MyFunction.
Nov 18 '05 #4

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

Similar topics

2
by: Gary | last post by:
Hi, I am a Chinese student, I have a problem with the following code //The follwing code in StaticSearch.h: // template <class Type> class dataList; // template <class Type> class Node ...
0
by: Fabrizio | last post by:
Hi, I'm using a datalist with a LoadTemplate method from an ascx(text format) file. Everything is working fine till i need to find a control within the datalist in the datalist_itemdatabound event....
4
by: Marina | last post by:
Hi, There is a component that is binding the results of a search to a DataList. By clicking on an image in the datalist, the user can download that particular item. We are using the DataKeys...
0
by: Barry | last post by:
Hi, I have a template in a DataList. The template also contains a DataList. I'd like to bubble the OnItemCommand event from the template's DataList up the hierarchy. Here's what I've tried so...
3
by: moondaddy | last post by:
using vb.net 1.1 I have a datalist and in it's item template I have 2 buttons, 'edit' and 'ShipToThisAddress'. The edit button works fine and it opens up the edit template as it works with the...
3
by: mbailey | last post by:
Hello- I am failry new to asp.net but have been coding in general for a while. I have a datalist whos templates are built on the fly. In the Page_Init sub, based on a certain value, certain...
1
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing...
2
by: hussainiyad | last post by:
Hi to all i today installed tthe v.b 6.0 in my system and i found 2 main problems problem1>--.I couldn,t able to open the data Project ,we know it contains two components one is data Environment...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
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
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...
1
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...
0
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,...
0
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...
0
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...
0
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 ...
0
muto222
php
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.