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
Ajit N
NA
352
71.5k
How to Show Image in new Tab on gridview image button click?
Jun 29 2019 10:35 PM
Hello, I want to show image in new tab when i click on particular image button in GridView. i tried some code which i mentioned below,but it didn't work for me. so help me how can i do this.
Front End Code
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
CssClass
=
"table table-bordered table-hover"
DataKeyNames
=
"ID"
OnRowCommand
=
"GridView1_RowCommand"
OnSelectedIndexChanged
=
"GridView1_SelectedIndexChanged"
EmptyDataText
=
"No records has been added."
AutoGenerateColumns
=
"False"
>
<
Columns
>
<
asp:BoundField
DataField
=
"ID"
HeaderText
=
"ID"
/>
<
asp:TemplateField
HeaderText
=
"Photo"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"imgRedirect"
runat
=
"server"
Height
=
"50px"
Width
=
"50px"
ImageUrl
=
'<%# Eval("img") %>'
OnClick
=
"imgRedirect_Click"
/>
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
Backend Code
protected
void
imgRedirect_Click(
object
sender, ImageClickEventArgs e)
{
int
getid = Convert.ToInt32(GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text);
string
imagename =
string
.Empty;
con.Open();
SqlCommand cmd =
new
SqlCommand(
"select * from AddPrescription where ID='"
+ getid +
"'"
, con);
SqlDataReader dr = cmd.ExecuteReader();
if
(dr.Read())
{
imagename = dr[
"img"
].ToString();
}
con.Close();
Response.Redirect(imagename);
}
Reply
Answers (
2
)
Cycle my question
diffrent year and month