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

Posted by: roberto_tomasi on 9 November 2020, 11:11 pm EST

    • Post Options:
    • Link

    Posted 9 November 2020, 11:11 pm EST

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

    any idea?

  • Posted 10 November 2020, 6:19 pm 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 3 January 2021, 11:15 pm 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, 4:48 am 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