[Solved] Binary Images are not displaying in ASP.Net GridView

Last Reply 10 months ago By akhter

Posted 10 months ago

I am trying to display image in gridview but images are not getting display in gridview.



Posted 10 months ago Modified on 10 months ago

i was just making a mistak that in FindControl, i was using column "Data" instead of ID ("img") .

protected void gvDepartments_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            DataRowView dr = (DataRowView)e.Row.DataItem;
            string imageUrl = "data:image/jpg;base64," + Convert.ToBase64String((byte[])dr["Data"]);
            (e.Row.FindControl("img") as System.Web.UI.WebControls.Image).ImageUrl = imageUrl;
    catch (Exception ex)
    { }