Bineeshcp Viswanath

Bineeshcp Viswanath

  • NA
  • 140
  • 39.8k

System.Byte[] showing in Gridview Column in ASP.NET C#

Apr 12 2019 2:49 AM
Hi All,
 
I am facing a discrepancy in loading image into gridview column in asp.net using c#.
 
My gridview has action with/without images. Action with images showing System.Byte[]. Please find screenshot below.
 
 
I don't want to show  System.Byte[] in the column. I already wrote a .css class to assign a icon to that column control. That image is displaying . I need your help to remove System.Byte[] and only to show that icon.
 
 
 
Here is my table where store image:-
 
 
 
SQL stored procedure i using to bind the gridview
  1. SELECT tblActionDetaills.FID,tblVilla.VillaName,tblActionDetaills.VID,tblActionDetaills.AdminUserID,  
  2. tblImageDetails.Image,  
  3. Convert(varchar(20),EventDate,103) as EventDate,  
  4. REPLACE(SUBSTRING(CONVERT(nvarchar(128),EventDate, 109), 12 , 128),':000'' 'as EventTime,  
  5. Description,Comment FROM tblActionDetaills inner join tblVilla on tblVilla.VID=tblActionDetaills.VID  
  6. inner join tblUserLogin on tblUserLogin.UserID=tblVilla.UserID  
  7. left join tblImageDetails on tblImageDetails.FID=tblActionDetaills.FID  
  8. WHERE tblUserLogin.UserID=@UserID  
  9. order by Convert(datetime,EventDate,103) desc 
.aspx code where binding in gridview
  1. <asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="View Image" HeaderStyle-HorizontalAlign="Center">  
  2. <ItemTemplate>  
  3. <asp:LinkButton ID="LinkButton1" CssClass="lnkbtnSelect" CommandName="LoadImage" Text='<% # Eval("Image")%>' CommandArgument='<%#Eval("FID")%>' runat="server">View Image</asp:LinkButton>  
  4. </ItemTemplate>  
  5. </asp:TemplateField> 
And C# code where I wrote to bind gridview
  1. using (SqlDataAdapter adapter = new SqlDataAdapter("LoadVillaDetailsForGridForCustomer", clsConObj.sqlCon))  
  2. {  
  3. adapter.SelectCommand.Parameters.Add("@UserID", SqlDbType.SmallInt).Value = Session["UserID"].ToString();  
  4. adapter.SelectCommand.CommandType = CommandType.StoredProcedure;  
  5. DataTable dtbl = new DataTable();  
  6. adapter.Fill(dtbl);  
  7. {  
  8. grdConstructionDetails.DataSource = dtbl;  
  9. grdConstructionDetails.DataBind();  
  10. grdConstructionDetails.HeaderRow.TableSection = TableRowSection.TableHeader; //added by sai on 09/04/2019 for lbl  
  11. lblTotalRecords.Text = Convert.ToInt16(dtbl.Rows.Count).ToString();  
  12. }  


Answers (10)