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 🙂
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.
LikeLike
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.
LikeLike
everest suggestion is good. EnableViewState=False casuing the problem. then i change to EnableViewState=True now i havent receive the error
LikeLike
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!
LikeLike
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.
LikeLike