尝试从辅助函数中获取一些字节数组到属性中
我试图将一些二进制数据放入“DataValue”属性中,如下面的控件所示。
<telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" AutoAdjustImageControlSize="false"
DataValue='<%# getBinary(); %>' />
DataValue 字段接受 byte[] 。
我的代码如下所示
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;
}
注意:该控件位于转发器控件内
我如何将字节数组获取到上述控件的 DataValue 属性中?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息和您的标记不一致:在标记中您使用数据绑定语法
<%# ... %>
(以#
开头)但错误消息报告了一个代码块<% ... %>
。在控件属性内使用代码块是无效的 ASP.NET,文本按字面解释,因此不会被识别为字节数组。确保您使用数据绑定语法,您可以仔细检查吗?
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?