I have an aspxgridview control that from time to time throws an error: DataBinding: 'DevExpress.Web.Data.WebDataRow' does not contain a property with the name 'Relevanta'.
I checked the stored procedure that binds to the grid and the field it's there.
This is the aspx code where the stack trace points.
<dxwgv:GridViewDataColumn FieldName="Relevanta" Caption="Relevanta">
<CellStyle HorizontalAlign="Left"></CellStyle>
<DataItemTemplate>
<div style="width:100%;background-color:#FFFFFF;height:6px;border:1px solid #808080">
<div style='background-color:#2a5f99;width:<%#(10 * Convert.ToInt32(DataBinder.Eval(Container.DataItem, "Relevanta"))).ToString()%>%;height:6px;'></div>
</div>
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
thanks
WebDataRow does not contain a property with the name
Answers approved by DevExpress Support
Hello Dan,
I've compared your issue with the DevExpress.Web.Data.WebDataRow' does not contain a property with the name report, and I assume that the grid doesn't have the datasource at the moment of binding. Can you try to change your code in the following way, and test that the DataBinder provides correct data:
ASPx<dxwgv:GridViewDataColumn FieldName="Relevanta" Caption="Relevanta">
<CellStyle HorizontalAlign="Left"></CellStyle>
<DataItemTemplate>
<div style="width:100%;background-color:#FFFFFF;height:6px;border:1px solid #808080">
<div style='<%# GetText(Container) %>'></div>
</div>
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
C#public String GetText(Object container) {
GridViewDataItemTemplateContainer cont = container as GridViewDataItemTemplateContainer;
// check this string: container.DataItem != null
Object rel = DataBinder.Eval(cont.DataItem, "Relevanta"); // rel isn't null or empty
Int32 width = 10 * Convert.ToInt32(rel);
return String.Format("background-color: #2a5f99; width: {0}; ;height:6px;", width);
}
If my tips don't help you, please provide a small example, so I can reproduce the issue on my side, or the ASPX page layout, so I can create an example by myself.
Thanks,
Vest
Hello Dave,
I am not sure about the use of the Bind method. It cannot replace the GetText method since the latter contains additional logic rather than simple binding to a data field.
If you wish to replace the DataBinder.Eval method, I am afraid that it is impossible since the DataBinder class does not provide the method for two-way data binding ('Bind').