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

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 (1, 2).

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

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

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
   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
      useDataBinding) in
   uSwitch.Web.UI.Lego.RepeatingInputRow.DataBind() in
   Owentest.Page_Load(Object sender, EventArgs e) in
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object
      o, Object t, EventArgs e) +13
      sender, EventArgs e) +45
   System.Web.UI.Control.OnLoad(EventArgs e) +80
   System.Web.UI.Control.LoadRecursive() +49
      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. If you don’t want to leave thoughts as a comment on here, feel free to email me (owenblacker at uswitch dot com). Cross-posted to and .


And more update…

[This post was made by email on the evening of Thursday 13th, but appeared at LiveJournal at 2am on Wednesday 19th Orange seem to have taken nearly a week to deliver it!]

Well, I’m now sat on the tube, opposite a really rather hot guy who’s too close by to tubestalk, so I figured I’d blog some. I’ll add some links into this once I get home and have an actual computer in front of me, with real windows and stuff.

Things I didn’t mention in my last post. Well, Ewan, Vikki, Eilidh and Mairi popped in to visit on Saturday, as did the fabulous Lee. I took (and Flickr’d) loads of photos of the Spence clan, wth Eilidh looking pticly adorable, Lee regaled us with fabulous tales of his ventures to all sorts of places, giving us some of the tidbits he hasn’t blogged, James () was down for the weekend, too, as I mentioned, and, generally, a good time was had by all.

I chatted with fy mam for a while on the phone, which was good. Apparently she’s getting an Internet-ready PC in some scheme the government is doing to encourage companies to part-subsidise computers for their employees, which will be kinda cool, though presumably means I’m gonna be designated Tech Support officer. I might have to introduce the concept that Scott () is much better at that than I… ;o)

I got a bit of a bollocking at work today for spending too much time doing things that aren’t my current project (mainly helping out the other guys in the team, but also Flickring whilst I wait for things to compile and so on), so I’m gonna be making more of an effort to be visibly better at that over the next few weeks. This means I might finally get round to setting up a work MSN account, which is a bit of a drag, but is something I prolly should’ve done ages ago. Needless to say, just about anyone who’s reading this isn’t gonna be on that list, for the sake of avoiding distractions. You all know how to text me anyways, so I’m not gonna lose much sleep over it. (If anyone reading doesn’t have my mobile number and wants it, leave a comment to that effect and I’ll almost certainly let you have it. If this means I start getting lots more texts at work, though, don’t expect me to jump to answer, eh? ;o)

Other than that, work’s going relatively well, though. I’m finally beginning to get my head round Microsoft Commerce Server. A few things are a little perverse and counterintuitive (why should I have to fetch all the product properties just to be able to get the display-name, when obvious things, like SKU and price are fetched by default when calling Category.GetProducts(), for example?!) but I’ve mainly managed to get my head round how various bits work, and we finally finished getting my machine set up for development today. Not a moment too soon, happen, as IT need it back to prepare for a new starter coming in on Monday. It’ll be good to get the deskspace back too. Think I’m gonna quite enjoy working on the project, though; the Conchango guys are all pretty cool and there’s plenty I can learn from them, as well as it being a site that’s gonna look good in our portfolio (and on my CV).

In other work news, we’re all pretty stoked atm, as Allied Domecq, last autumn’s labor of love, has been nominated for two BIMA awards, which is pretty awesome. It’s about time some of the stunning work we all put into that actually won us some silverware and greater renown.

Last night was a little odd. Some minor filth here

Quick update

New meds are much better when I take them in the evening with food. Took them a little late last night, and haven’t had as much sleep as I’d like (had a bit of a drama last night that I sha’n’t go into in public), so I’m a bit shaky this morning, both physically and emotionally, but so far so good.

No idea what the fuck I can wear today that’ll be cool enough for the heat, but good enough to deal with thunderstorms later. Can’t wear canvas shoes if they might get wet, after all.

Work is being so-so. A rant to my boss on Wednesday (about one of my colleagues who hadn’t done what I thought he’d said he had) turned into him railing about my punctuality, which pissed me off muchly, as he knows that it’s not as simple as me getting up too late (and public transport in this city collapses completely when it gets too warm!) and making reasonable adjustments for my disabilities is something my employers are mandated to do under the Disability Discrimination Act 1995. Though, for me, the key issue is that my hours are broadly predictable, I let people know when I’m running late (with an ETA) and I always work more than my 37,5 hours a week!

Also, I’ve been booked, for the last two days, to scope, design and build a content-managed extranet for one of our larger clients, though I spent all of Wednesday on the client–server app thing and all of yesterday on NS&I, having swapped today’s and yesterday’s time around in the schedule.

Anyways, must dash, otherwise I’ll be late again, which would be bad.