-22

I have an in-memory DataSet bound to an ASPxGridView where the column names are determined by a variable. Now I would prefer to assign the FieldName of the columns in the markup with the value of the corresponding variable, but <%#Eval(...)%> throws the following error.

Parser Error Message: Databinding expressions are only supported on objects that have a DataBinding event. DevExpress.Web.ASPxGridView.GridViewDataTextColumn does not have a DataBinding event.

Is it possible to assign the FieldName-Attribute of a GridViewDataTextColumn with a variable in the markup?

From

<dx:GridViewDataTextColumn Caption="Product" FieldName="product_name">

To

<dx:GridViewDataTextColumn Caption="Product" FieldName="<%# Eval("ProductFieldName") %>">
Andreas
  • 21,535
  • 7
  • 47
  • 56

1 Answers1

-1

No, in general. The GridViewDataTextColumn is a hierarchycal (non Data-Bound) element and it is not contained into a Data-Bound container.

According to the exception's message, I believe this is a common situation for such an ASP.NET controls:

DataBinding expressions are only supported on objects that have a DataBinding event.

I believe it is possible to specify the required properties and assign column FieldName at runtime as it is illustrated here.

Mikhail
  • 9,186
  • 4
  • 33
  • 49
  • Thanks :) I already knew the way doing it at runtime. I thought I missed something so it could be done the other way directly in the markup. – Andreas Mar 29 '12 at 06:40