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 :)

Advertisements

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

  1. 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

  2. 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

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

    Like

  4. 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

  5. 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s