Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
GridView image popup using JQuery and asp.net
Posted by
Abhijit barua
in
Blogs
|
.NET 4.5
on
Jan 23, 2012
GridView image popup using JQuery and asp.net
Tweet
1340
0
0
Download Files:
GridView image popup using JQuery and asp.net.rar
First of all i create one table with three field(id,ImageName,ImagePath). I save image path at database and image at folder. To do these you will required JQuery and CSS file which i mention below.(Download code there you will get jquery and css file).
<link href="css/lightbox.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
Below i show the design page gridview portion.
<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" ShowHeader="true"
CellPadding="5">
<Columns>
<asp:TemplateColumn HeaderText="Photo">
<ItemTemplate>
<a href='<%#GetDetail(DataBinder.Eval(Container.DataItem,"id"))%>' rel="lightbox"
title='<%#title(DataBinder.Eval(Container.DataItem,"ImageName"))%>'>
<img height="100" width="90" style="border: Solid 1px Black;" src='<%#GetDetail(DataBinder.Eval(Container.DataItem,"id"))%>' />
</a>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Gridview bind at page load like below
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
con = new SqlConnection("Data Source=server name;Initial Catalog=database name;Integrated Security=SSPI;");
cmd.Connection = con;
cmd.CommandText = "Select * from imagetable";
con.Open();
DataGrid1.DataSource = cmd.ExecuteReader();
DataGrid1.DataBind();
con.Close();
Now Look at below line through which when gridview image is click it show image at popup.
src='<%#GetDetail(DataBinder.Eval(Container.DataItem,"id"))%>'
I write server side code to get image for respective id, like below and when you click at gridview image it's directly go to server side and check GetDetail().
public string GetDetail(object objEmplayeeId)
{
string constr = "Data Source=Subhasish-PC;Initial Catalog=testabhijit;Integrated Security=SSPI;";
int EmplayeeId = int.Parse(objEmplayeeId.ToString());
//string path = table.Rows[0]["ImagePath"].ToString();
string query = "SELECT ImagePath FROM imagetable WHERE id = '" + EmplayeeId + "'";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
string path = table.Rows[0]["ImagePath"].ToString();
return path;
}
You can download the code attach with these tutorial. Happy codding.
share this blog :
Binding ajax popup extender with..
VS 2010 Keyboard Shortcut posters
Related Blogs
Javascript mouse over gridview row highlighted
TextBox validation using JQuery
How to use Web Browser Control in .Net
How to create Datapager Gridview in asp.net.
Want to develop for Social Networking using ASP.Net 4.0? Then grab the book ASP.Net 4.0 Social Networking authored by Atul Gupta
Data Entry In Gujarati Using Asp.net and SQL Server
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Shopping cart add more, remove functionality using view state
Create dynamic accordion pane and bind with varbinary data
Select query on datatable for filter data
Binding ajax popup extender with database value.
Select Query on DataTable for filtering Data Using LINQ
Create database table using c#.net with variable of table name
GridView image popup using JQuery and asp.net
select query on datatable for filter data
View All
Latest Blogs
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
JQuery Maxchars Plugin
View All
Sponsored by
Become a Sponsor