Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Owen Blacker #1
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
[url]http://www.webswapp.com/codesamples/aspnet20/dependentlists/default.aspx[/url]
(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 ([url]http://masl.to/?S11823B6D[/url] and [url]http://masl.to/?P40821B6D[/url], 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<Pair> gives 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: [url]www.no2id.net[/url]
Get your mits off my bits: [url]www.openrightsgroup.org[/url]
--
Those who would give up essential liberty to purchase a little
temporary safety, deserve neither liberty nor safety -- Benjamin
Franklin, 1759
Owen Blacker Guest
-
Custom Templated Databound Control or derived control?
Hi, I want to create a control that performs much like a datalist but I want more control over how the <ItemTemplate> contents is set out on the... -
Composite control delegating databound templated features to child <asp:repeater> control
Hi Everybody, I'm creating a composite control in C# that basically renders a bunch of webcontrols such as <asp:Label />, <asp:Repeater />,... -
web Navigator Databound Control
Hello, I Can not make this Navigator (Superexpert DataForm ) work on Oracle using the OLEDB part of it although the SQLDB works perfectly fine. ... -
Control derived from datagrid, problem with adding other control and databinding (VB)
I all, my employer required me to add a bunch of control to a datagrid (such as a drop down list on top corner to select page size and prev, bunch... -
Eval and methods
How do you do meta type stuff in Ruby? E.g. a_method = "to_str" an_attribute = "color" class Toad attr_accessor :color def initialize( c )... -
Phillip Williams #2
RE: Databinding methods such as Eval(), XPath(), and Bind() can only b
Owen,
Can you post the entire page code that causes this problem?
--
HTH,
Phillip Williams
[url]http://www.societopia.net[/url]
[url]http://www.webswapp.com[/url]
"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
> [url]http://www.webswapp.com/codesamples/aspnet20/dependentlists/default.aspx[/url]
> (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 ([url]http://masl.to/?S11823B6D[/url] and [url]http://masl.to/?P40821B6D[/url], 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<Pair> gives 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: [url]www.no2id.net[/url]
> Get your mits off my bits: [url]www.openrightsgroup.org[/url]
> --
> Those who would give up essential liberty to purchase a little
> temporary safety, deserve neither liberty nor safety -- Benjamin
> Franklin, 1759
>
>Phillip Williams Guest



Reply With Quote

