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
- SELECT tblActionDetaills.FID,tblVilla.VillaName,tblActionDetaills.VID,tblActionDetaills.AdminUserID,
- tblImageDetails.Image,
- Convert(varchar(20),EventDate,103) as EventDate,
- REPLACE(SUBSTRING(CONVERT(nvarchar(128),EventDate, 109), 12 , 128),':000', ' ') as EventTime,
- Description,Comment FROM tblActionDetaills inner join tblVilla on tblVilla.VID=tblActionDetaills.VID
- inner join tblUserLogin on tblUserLogin.UserID=tblVilla.UserID
- left join tblImageDetails on tblImageDetails.FID=tblActionDetaills.FID
- WHERE tblUserLogin.UserID=@UserID
- order by Convert(datetime,EventDate,103) desc
.aspx code where binding in gridview
- <asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="View Image" HeaderStyle-HorizontalAlign="Center">
- <ItemTemplate>
- <asp:LinkButton ID="LinkButton1" CssClass="lnkbtnSelect" CommandName="LoadImage" Text='<% # Eval("Image")%>' CommandArgument='<%#Eval("FID")%>' runat="server">View Image</asp:LinkButton>
- </ItemTemplate>
- </asp:TemplateField>
And C# code where I wrote to bind gridview
- using (SqlDataAdapter adapter = new SqlDataAdapter("LoadVillaDetailsForGridForCustomer", clsConObj.sqlCon))
- {
- adapter.SelectCommand.Parameters.Add("@UserID", SqlDbType.SmallInt).Value = Session["UserID"].ToString();
- adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataTable dtbl = new DataTable();
- adapter.Fill(dtbl);
- {
- grdConstructionDetails.DataSource = dtbl;
- grdConstructionDetails.DataBind();
- grdConstructionDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
- lblTotalRecords.Text = Convert.ToInt16(dtbl.Rows.Count).ToString();
- }
- }