How to view a blob Image field into Imagefield in wijmo:C1GridView

Posted by: roberto_tomasi on 10 November 2020, 8:11 am EST

    • Post Options:
    • Link

    Posted 10 November 2020, 8:11 am EST

    Hi i must to view a blob Image field from Sql Server into Imagefield in wijmo:C1GridView

    any idea?

  • Posted 11 November 2020, 3:19 am EST

    Hi Roberto,

    We are sorry for the inconvenience, we are unable to find a way to show the Image from Blob. Hence, we have forwarded this to the concerned team for further investigation with the internal tracking id C1WEB-27503.

    Regards,

    Manish Gupta

  • Posted 4 January 2021, 8:15 am EST

    Hi Roberto,

    Please try to use the following code:

    Server-side: Create a method that converts to base 64 string from a byte array stored in DB

    // Convert by to string base 64
    protected string GetImageFromBlob(byte[] data)
    {
        string base64String = Convert.ToBase64String(data);
        return String.Format("data:image/jpg;base64,{0}", base64String);
    }
    

    Client-side: Call method in server-side to get the image source because image source must be a string

    <wijmo:C1TemplateField HeaderText="Image"> 
        <ItemStyle HorizontalAlign="Center" /> 
        <ItemTemplate> 
            <img src='<%# GetImageFromBlob((byte[])Eval("Image")) %>' alt=<%# Eval("Image") %> /> 
        </ItemTemplate> 
    </wijmo:C1TemplateField>
    

    Hope it helps!

    Regards,

    Manish Gupta

  • Posted 4 January 2021, 1:48 pm EST

    Hi Manish

    Thank for your reply

    but i already solved

    in this way

    
    
    on grid row i added  
    	OnRowDataBound="grdConsegna_RowDataBound" 
    
    in the columns
    
    <wijmo:C1BoundField DataField="Immagine" HeaderText="Immagine"  
               Visible="false"> </wijmo:C1BoundField>
    <wijmo:C1TemplateField >
                <ItemTemplate>
                           <asp:Image ID="myIMG" runat="server" ImageUrl="" Width="240px" 
                                        Height="180px" />
                  </ItemTemplate>
      </wijmo:C1TemplateField>
    
    

    and in vb.net

    
     Protected Sub grdConsegna_RowDataBound(sender As Object, e As 
                  C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowEventArgs)
            ' cambio l'image url al controllo image del template da me definito
    
    
            If e.Row.RowType = DataControlRowType.DataRow Then
                  DirectCast(e.Row.Cells(5).FindControl("myIMG"), Image).ImageUrl = 
                                         "getImage.aspx?ID=" & e.Row.Cells(0).Text
            End If
        End Sub
    
    

    at the next time

    bye

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels