TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Riddhi Valecha
444
3.3k
412.6k
Display Image In GridView
Oct 1 2020 12:17 PM
Dear Team,
I need help in displaying images from folder to gridview rows.
I am sharing my code -
ASPX Page -
<asp:GridView runat=
"server"
CssClass=
"mytable mytable2"
ID=
"gvdetail"
AutoGenerateColumns=
"false"
GridLines=
"None"
>
<Columns>
<asp:TemplateField HeaderText=
"Question"
ItemStyle-Wrap=
"true"
>
<ItemTemplate>
<%#Eval(
"Question"
)%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=
"Answer"
HeaderText=
"Answer"
/>
<asp:TemplateField HeaderText=
"Remark"
ItemStyle-Wrap=
"true"
>
<ItemTemplate>
<%#Eval(
"Remark"
)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID=
"imgForReqid"
runat=
"server"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code -
Protected
Sub
grdmis_RowCommand(sender
As
Object
, e
As
GridViewCommandEventArgs)
Handles
grdmis.RowCommand
Try
Dim
reqid
As
String
=
""
Dim
rowIndex
As
Integer
= Convert.ToInt32(e.CommandArgument)
reqid = grdmis.DataKeys(rowIndex).Values(
"REQID"
)
If
e.CommandName =
"Select"
Then
Dim
sqldata
As
String
=
String
.Empty
sqldata =
" select q.QUEST as Question,a.ANS_VAL as Answer,d.REMARKS as Remark , i.filename from HKC_REQ_DTL d "
sqldata &=
" join HKC_QUEST_MAST q"
sqldata &=
" on d.QID=q.QID inner join HKC_ANS_MAST a on d.aid=a.AID "
sqldata &=
" join doclink i on d.reqid=lpad(i.docno,30,0)"
sqldata &=
" where reqid='"
& reqid.ToString().Trim() &
"' and doctype='HKC'"
Dim
clsobject
As
New
clsbase
dtimages = clsobject.fnselect(sqldata)
If
dtimages.Rows.Count > 0
Then
Dim
ImagePaths()
As
String
= Directory.GetFiles(Server.MapPath(
"~/TempFile/"
))
Dim
Imgs
As
List(Of ListItem) =
New
List(Of ListItem)
Dim
ImgName
As
String
' Dim imgbtn As System.Web.UI.WebControls.Image = CType(e.CommandSource, System.Web.UI.WebControls.Image)
For
Each
dr
In
dtimages.Rows
For
Each
imgPath
As
String
In
ImagePaths
ImgName = Path.GetFileName(imgPath)
If
ImgName.ToString().Trim() = dr(
"filename"
)
Then
ImgName = Path.GetFileName(imgPath).Trim()
Imgs.Add(
New
ListItem(ImgName, (
"~/TempFile/"
+ ImgName)))
imgForReqid.ImageUrl = imgPath
End
If
'ImgName = Path.GetFileName(imgPath)
'Imgs.Add(New ListItem(ImgName, ("~/TempFile/" + ImgName)))
Next
Next
gvdetail.DataSource = dtimages
gvdetail.DataBind()
gvdetail.HeaderRow.TableSection = TableRowSection.TableHeader
mfn_Get_PopUp(popupdiv2,
"90%"
,
"90%"
,
"Checklist detail"
)
End
If
'gvdetail.DataSource = objcom.GetchkDetail(reqid)
'gvdetail.DataBind()
'gvdetail.HeaderRow.TableSection = TableRowSection.TableHeader
'mfn_Get_PopUp(popupdiv2, "90%", "90%", "Checklist detail")
End
If
Catch
ex
As
Exception
End
Try
End
Sub
Reply
Answers (
4
)
how to import csv file into sql server in asp.net c#
Posting form data using jquery ajax with html