I
Interraptor
Guest
Hello,
I'm trying to bind a Byte[] Array with asp.image as follow
var. 1
<ItemTemplate>
<asp:Image ID="Image2" runat="server" ImageUrl='<%# String.Format("data:image/jpeg;base64,{0}",((byte[])Eval("Picture")) ) %>' />
and also var. 2 with Code
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
string imageUrl = "data:image/jpg;base64," + Convert.ToBase64String((byte[])rowView["Picture"]);
object o = e.Item.FindControl("Image1");
Image i = (Image)o;
if (i != null)
(e.Item.FindControl("Image1") as Image).ImageUrl = imageUrl;
}
}
But I can't get a Picture on ASP.NET PAge.
Whats wrong? And how can I achive this Goal?
Thanks
P.S. Visual Studio 2019, Database Nordwind, Table Categories
Make IT better.
Continue reading...
I'm trying to bind a Byte[] Array with asp.image as follow
var. 1
<ItemTemplate>
<asp:Image ID="Image2" runat="server" ImageUrl='<%# String.Format("data:image/jpeg;base64,{0}",((byte[])Eval("Picture")) ) %>' />
and also var. 2 with Code
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;
string imageUrl = "data:image/jpg;base64," + Convert.ToBase64String((byte[])rowView["Picture"]);
object o = e.Item.FindControl("Image1");
Image i = (Image)o;
if (i != null)
(e.Item.FindControl("Image1") as Image).ImageUrl = imageUrl;
}
}
But I can't get a Picture on ASP.NET PAge.
Whats wrong? And how can I achive this Goal?
Thanks
P.S. Visual Studio 2019, Database Nordwind, Table Categories
Make IT better.
Continue reading...