错误:无法将类型为“System.Int32”的对象强制转换为“System.Byte []” [英] Error: Unable to cast object of type 'System.Int32' to type 'System.Byte[]'
本文介绍了错误:无法将类型为“System.Int32”的对象强制转换为“System.Byte []”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Line 54: <itemtemplate>
Line 55: <asp:Image ID="Image1" runat="server" ImageUrl='<%# "data:b/jpg;base64," + Convert.ToBase64String((byte[])Eval("a")) %>' Height="150px" Width="150px"/>
Line 56: </itemtemplate>
推荐答案
似乎Eval(a)
(无论是什么)返回Int32
值...你不能将int转换为字节数组 - 你需要转换它...
试试这个:
It seems thatEval("a")
(whatever it is) returns anInt32
value...You can not cast an int to a byte array - you need to convert it...
Try this:
BitConverter.GetBytes(Eval("a"))
HTT ps://msdn.microsoft.com/en-us/library/de8fssa4(v = vs.110).aspx [ ^ ]
你可以使用BitConverter class [ ^ ]。
这篇关于错误:无法将类型为“System.Int32”的对象强制转换为“System.Byte []”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文