Categories
Geeky/Programming

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

Blah – I hate stupid error messages. Basically everywhere you look to see what causes this, it has something to do with cacading drop downs. I have ran into this error twice and the fix is – change a “=” to a “#”

if you have in your aspx page

it will throw that error if it is in a repeater or data control. Change it to

and viola! it works 🙂

By Steve Novoselac

Director of Digital Technology @TrekBikes, Father, Musician, Cyclist, Homebrewer

5 replies on “Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.”

This is not always the case though. It happens in other situations like binding to data grid caused by another control. One solution I found was disable the view state of that page if you are binding the bound control each time you load the page.

Like

Aww man, what a pain.
I’m using a bunch of SqlDataSources in one page (nothing in codebehind). The first SqlDataSource is used as a source for some dropdownlists. If I update this datasource then I receive that error.

Like

everest suggestion is good. EnableViewState=False casuing the problem. then i change to EnableViewState=True now i havent receive the error

Like

Everest’s suggestion fixed my problem. I disabled viewstate on the page, in the declarations section, and everything worked perfectly. As he/she mentioned, I am binding a DataList inside a bound FormView.

Thanks Everest!

Like

Got the problem when binding GridView to ObjectDataSource, then inserting a row on a button click. Everest got me thinking; solution was to disable ViewState on ObjectDataSource.

Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.