I am trying to get some binary data in to the "DataValue" attribute as in the below control.
<telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" AutoAdjustImageControlSize="false"
DataValue='<%# getBinary(); %>' />
the DataValue field accepts a byte[] .
my code behind looks like this
public byte[] getBinary()
{
TestDBDataContext db = new TestDBDataContext();
var r = (from a in db.ImageTables where a.Id == 22 select a).FirstOrDefault();
byte[] bt = r.Thumbnail.ToArray();
return bt;
}
NOTE: The control is inside a repeater control
How could I get byte array in to the DataValue attribute on the above control ?
The error message and your markup are not consistent: in your markup you use data binding syntax <%# ... %>
(with the #
at the beginning) but the error message reports a code block <% ... %>
.
Using a code block inside a control attribute is not valid ASP.NET, the text is interpreted literally, and thus is not recognized as a byte array. Make sure you use data binding syntax, can you double check?