Akhter HUssain

Akhter HUssain

  • 1.2k
  • 692
  • 12.1k

Unable to cast object of type System.String to type System.B

Sep 23 2019 6:30 AM
I am passing data from one page to another page, but one image this exception is being raised that
 
Unable to cast object of type System.String to type System.Byte.
 
here is my second page html of image..
  1. <asp:TemplateField HeaderText="Image">  
  2. <ItemTemplate>  
  3. <%--<asp:Image ID="img" runat="server" ImageUrl='<%# Eval("Data").ToString() %>' Height="100px" Width="100px" />--%>  
  4. <asp:Image ID="Data" runat="server" Width="100px" Height="80px" ImageUrl='<%# "data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("Data")) %>' />  
  5. </ItemTemplate>

Answers (3)