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

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control

I've spent loads of time Googling to try to work this one out and I'm
sure it's something obvious.

I get an InvalidOperationException reading "Databinding methods such as
Eval(), XPath(), and Bind() can only be used in the context of a
databound control" when I start my page. Unless I'm missing something
obvious, this is *not* the same issue as the "2-way databinding
cascading lists" issue in
http://www.webswapp.com/codesamples/...s/default.aspx
(which is linked from everywhere; I kinda wish that were my problem ;o)

I have a templated databound custom server control, that I've built
with
a great deal of help from the two articles by 4GuysFromRolla's Scott
Mitchell (http://masl.to/?S11823B6D and http://masl.to/?P40821B6D, both
on msdn.microsoft.com).

I don't seem to be able to use databinding syntax, however:

<ItemTemplate>
<asp:TableCell runat="server"><%# Eval("First")
%></asp:TableCell>
...
</ItemTemplate>

bound to a List<Pairgives me an exception:

[InvalidOperationException: Databinding methods such as Eval(),
XPath(),
and Bind() can only be used in the context of a databound control.]
System.Web.UI.Page.GetDataItem() +90
System.Web.UI.TemplateControl.Eval(String expression) +110
ASP.owentest_aspx.__DataBind__control8(Object sender, EventArgs e)
in
c:\Projects\Customisation\RedesignProtoTypeWeb\Owe ntest.aspx:13
System.Web.UI.Control.OnDataBinding(EventArgs e) +80
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +198
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +214
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +208
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +214
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +208
System.Web.UI.Control.DataBind() +12
uSwitch.Web.UI.Lego.RepeatingInputRow.CreateItem(I nt32 rowIndex,
Table container, Boolean useDataBinding, Object rowData) in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:361
uSwitch.Web.UI.Lego.RepeatingInputRow.CreateContro lHierarchy(Boolean
useDataBinding) in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:452
uSwitch.Web.UI.Lego.RepeatingInputRow.DataBind() in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:643
Owentest.Page_Load(Object sender, EventArgs e) in

c:\Projects\Customisation\RedesignProtoTypeWeb\Owe ntest.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object
o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object
sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +3716

I don't get the exception if my databinding control is outside the
table
cell but, for a handful of other reasons, including that my
ItemTemplate
is being instantiated inside a TableRow, that won't work for me.

Any ideas gratefully received, as I'm completely lost.
Owen
--
Owen Blacker, London GB
Say no to ID cards: www.no2id.net
Get your mits off my bits: www.openrightsgroup.org
--
Those who would give up essential liberty to purchase a little
temporary safety, deserve neither liberty nor safety -- Benjamin
Franklin, 1759

Jul 19 '06 #1
1 16212
Owen,

Can you post the entire page code that causes this problem?
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Owen Blacker" wrote:
I've spent loads of time Googling to try to work this one out and I'm
sure it's something obvious.

I get an InvalidOperationException reading "Databinding methods such as
Eval(), XPath(), and Bind() can only be used in the context of a
databound control" when I start my page. Unless I'm missing something
obvious, this is *not* the same issue as the "2-way databinding
cascading lists" issue in
http://www.webswapp.com/codesamples/...s/default.aspx
(which is linked from everywhere; I kinda wish that were my problem ;o)

I have a templated databound custom server control, that I've built
with
a great deal of help from the two articles by 4GuysFromRolla's Scott
Mitchell (http://masl.to/?S11823B6D and http://masl.to/?P40821B6D, both
on msdn.microsoft.com).

I don't seem to be able to use databinding syntax, however:

<ItemTemplate>
<asp:TableCell runat="server"><%# Eval("First")
%></asp:TableCell>
...
</ItemTemplate>

bound to a List<Pairgives me an exception:

[InvalidOperationException: Databinding methods such as Eval(),
XPath(),
and Bind() can only be used in the context of a databound control.]
System.Web.UI.Page.GetDataItem() +90
System.Web.UI.TemplateControl.Eval(String expression) +110
ASP.owentest_aspx.__DataBind__control8(Object sender, EventArgs e)
in
c:\Projects\Customisation\RedesignProtoTypeWeb\Owe ntest.aspx:13
System.Web.UI.Control.OnDataBinding(EventArgs e) +80
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +198
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +214
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +208
System.Web.UI.Control.DataBind() +12
System.Web.UI.Control.DataBindChildren() +214
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +208
System.Web.UI.Control.DataBind() +12
uSwitch.Web.UI.Lego.RepeatingInputRow.CreateItem(I nt32 rowIndex,
Table container, Boolean useDataBinding, Object rowData) in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:361
uSwitch.Web.UI.Lego.RepeatingInputRow.CreateContro lHierarchy(Boolean
useDataBinding) in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:452
uSwitch.Web.UI.Lego.RepeatingInputRow.DataBind() in

C:\Projects\uSwitch.Web\UI.Lego\InputModule\Repeat ingInputRow.cs:643
Owentest.Page_Load(Object sender, EventArgs e) in

c:\Projects\Customisation\RedesignProtoTypeWeb\Owe ntest.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object
o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object
sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +3716

I don't get the exception if my databinding control is outside the
table
cell but, for a handful of other reasons, including that my
ItemTemplate
is being instantiated inside a TableRow, that won't work for me.

Any ideas gratefully received, as I'm completely lost.
Owen
--
Owen Blacker, London GB
Say no to ID cards: www.no2id.net
Get your mits off my bits: www.openrightsgroup.org
--
Those who would give up essential liberty to purchase a little
temporary safety, deserve neither liberty nor safety -- Benjamin
Franklin, 1759

Jul 21 '06 #2

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

Similar topics

1
by: Joe Gass | last post by:
I'd like to bind some xml to a dropdownlist <engines> <engine name="test1" id="1" /> <engine name="test2" id="2" /> </engines> If I do: ddlEngines.DataSource =...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
8
by: Joey Chömpff | last post by:
L.S., Hello is there a way to implement 2-way databinding without using the datasources from dotnet 2.0. Why would you ask? Now that's simple. I've created an object model with BusinessObjects...
0
by: moi | last post by:
Hello, With ASP.NET 2 , i have two dropdownlist, one "A" (not in a formview) in the web page and other one "B" in a Insert Template in a formview. There's a link (parameter between this two...
1
by: Owen Richardson | last post by:
Hi I am confused with databinding - i have created repeaters and gridviews and i understand that <%# Eval("Price") %returns the value of price thats bound, and i even understand that i can do <%#...
1
by: neoupadhyay | last post by:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
0
by: Chris | last post by:
I am using databinding on a pair of cascading dropdowns. You select a team and get the office they can work in. When I try to rebind the second office dropdown I get the following error. ...
2
by: David C | last post by:
I have a drop down list control where I set AppendDataBound to true and added a list item of '<< add new>>' with a value of -1 to use for adding items to the list during data entry. When the user...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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
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,...

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.