Databinding methods such as Eval(), XPath(), and Bind() …

Discussion in '.NET' started by owenblacker, Jul 19, 2006.

  1. owenblacker

    owenblacker

    Joined:
    Jul 19, 2006
    Messages:
    1
    Location:
    London
    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
    (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:

    Code:
       <ItemTemplate>
          <asp:TableCell runat="server"><%# Eval("First") %></asp:TableCell>
       ...
       </ItemTemplate>
    bound to a List<Pair> gives me an exception:

    Code:
    [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\Owentest.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(Int32 rowIndex,
          Table container, Boolean useDataBinding, Object rowData) in
          C:\Projects\uSwitch.Web\UI.Lego\InputModule\RepeatingInputRow.cs:361
       uSwitch.Web.UI.Lego.RepeatingInputRow.CreateControlHierarchy(Boolean
          useDataBinding) in
          C:\Projects\uSwitch.Web\UI.Lego\InputModule\RepeatingInputRow.cs:452
       uSwitch.Web.UI.Lego.RepeatingInputRow.DataBind() in
          C:\Projects\uSwitch.Web\UI.Lego\InputModule\RepeatingInputRow.cs:643
       Owentest.Page_Load(Object sender, EventArgs e) in
          c:\Projects\Customisation\RedesignProtoTypeWeb\Owentest.aspx.cs:20
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object
          o, Object t, EventArgs e) +13
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(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
     
    owenblacker, Jul 19, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moi
    Replies:
    0
    Views:
    5,773
  2. yosri2005@gmail.com
    Replies:
    0
    Views:
    857
    yosri2005@gmail.com
    Dec 13, 2007
  3. Owen Blacker
    Replies:
    1
    Views:
    198
    Phillip Williams
    Jul 21, 2006
  4. Owen Blacker
    Replies:
    1
    Views:
    401
    Phillip Williams
    Jul 21, 2006
  5. Phillip Williams

    Databinding methods such as Eval(), XPath(), and Bind() can only b

    Phillip Williams, May 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    293
    dwg1011
    May 14, 2006
Loading...

Share This Page