Click here to Skip to main content
15,896,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am displaying images in gridview i want to zoom image and open in center when pointer goes to on that image. How can i do this?
Posted
Comments
P_Dash 19-Jan-13 15:00pm    
How are you providing data to GridView ?

I mean if you are Customizing columns manually Writing Templates then your requirement could be possible to achieve.

But if you are just using DataSet or any Data Source to automatically provide dat then I don't think your requirement could be achievable.

So plz rply here how you filling up data in GridView ?
Jigar Sangoi 20-Jan-13 2:44am    
I am using dataset but it is possible by using template then tell how can I do this
P_Dash 20-Jan-13 4:55am    
Let me try it.
If getting Successful will post the Code here.

1 solution

This solution will provide you zooming of the image present in GridView whenever mouse pointer hovers over it.

Step-1: Add GridView & Databinding for it according to your requirement.Change "AutoGenerateColumns" property of Gridview to False.
I hope you know how to use Templates to Show data in GridView.
So now add an Image control under Item Template as following:

ASP.NET
<asp:TemplateField HeaderText="Employee Image">
  <ItemTemplate>
    <asp:Image ID="gvImg" runat="server" ImageUrl="~/Images/1.jpg" CssClass="default" />
  </ItemTemplate>
</asp:TemplateField>


I've used a CSS Class, which I've provided below & an Image just for demo.You can use them according to your requirement.

Step-2: Write the following jQuery code in your page under Head section:
HTML
<style>
  .default 
   {
     width: 75px;
     height: 75px;
   }
</style>

<script src="Scripts/jquery-1.8.3.js"></script>
<script>
  $(document).ready(function () {
    //Using default CSS Class here for capturing the hover event
    $('.default').each(function () {
      $(this).hover(function () {
        $(this).animate({ width:100,height:120 }, 500);
      },
      function () {
        $(this).animate({ width:75,height:75 }, 250);
      });
    });
  });
</script>


Hover event takes 2 Functions.1st one when mouse pointer comes over Image & 2nd Function when mouse pointer goes out of Image control.

Now whenever mouse pointer will come over the Image control present in GridView, it'll zoom in & when mouse pointer goes out it'll zoom out.

Still you didn't get any point feel free to ask.
 
Share this answer
 
Comments
Jigar Sangoi 24-Jan-13 1:16am    
This code works good but problem is that images are resize in that template field only i want to display images in to new window using hover or onclick
P_Dash 24-Jan-13 2:05am    
See For New Window I don't Have Much Idea.
But Yes if you know how to use Ajax Control Toolkit, then you can use Popup Extender Control for this Purpose.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900