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

Last Reply one year ago By akhter

Posted one year ago

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



You are viewing reply posted by: akhter one year ago.
Posted one year ago Modified on one year 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)
    { }