.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Resize image in gridview

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

I have a database which stores the path of an image. When the gridview displays, it uses a template field to show the image instead of the path. 

<asp:TemplateField HeaderText="Image">
                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Image") %>' />


The images in this database may be different to eachother, but I want to resize each picture by a scale factor. Ie. Divide the height by 10, and then the width by 10, then set the height and width to these values. How can I do this for each image in the datagrid?

View Complete Post

More Related Resource Links

Easy image processing(grayscale, sepia, negative, resize, brightness, contrast and opacity)

Howdie y'all,

I see a lot of questions in this forum about resizing images. Recently I created a code sample(with downloadable webapp), right here.

The class (downloaded or created) allows for very fast and easy processing of your images. And a lot of problems over here can be solved by simply using that class. I thought it might help to mention the code sample in this forum as well.



Gridview with Image Button


i have a gridview and i want to perform edit and delete with an image button

but unable to figure out the events and how i m gonna make my grid into edit mode ??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                <asp:TemplateField HeaderText="S.No">
                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                <asp:TemplateField HeaderText="Edit">
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" 
                            ImageUrl="~/image/ico_edit.gif" CommandName="Edit" 
                            onclick="ImageButton1_Click" />
                <asp:TemplateField HeaderText="Delete">

How To display image in GridView as hyperlink


Hello Everyone 

Could someone please help me with a little issue....

I was able to save the image in the database as binary....... but now i don´t know how to display it in the GridView as a hyperlink.

I´ve read something about ImageField..... I´d appreciate any help .


Editing Image in Gridview VB.net

Hi, i'm back again and would like to seek help and advises from you experts on how to deal with problem. I have a table that accepts news data like title, content, link and a single image to be uploaded and attached to the database (not on file server). Now i want this Image Column (varbinary datatype) to be edited in case. When I tried puting an html fileupload in editing mode using gridview, I am getting error from the Image Column conversion like Image type cannot be converted into string. I know there is this scenario of reading and assigning data in my table, and then changing some codebehind and at the same time binding it into the gridview.This is my Image Handler:<%@ WebHandler Language="VB" %>Imports SystemImports System.WebImports System.ConfigurationImports System.Data.SqlClientPublic Class Handler : Implements IHttpHandler        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest        Dim con As New SqlConnection()        con.ConnectionString = ConfigurationManager.ConnectionStrings("automotiveConnectionString").ConnectionString                ' Create SQL Command           &n

Display image icon in HyperLinkField of Gridview

 Hello everyone! Can someone please tell me how to display an image in a HyperLinkField of a gridview?  Instead of words, I just want to show a simple little icon that can be clicked on and pass a query string to the next page.  The first hyperlink field I have set up works perfectly and passes the querystring to the next page.   The second hyperlinkfield is my attempt at showing the image but it's giving me a squiggly and telling me "the element img cannot be nested within the element hyperlinkfield" I got this technique from this brief article   - I would like to accomplish exactly what it says it is suppose to do. Thanks!   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="clientID"> <Columns> <asp:BoundField DataField="clientFirstName" HeaderText="First Name" /> <asp:BoundField DataField="clientLastName" HeaderText="Last Name" /> <asp:HyperLinkField HeaderText="More Info" Text="View more info..." DataNavigateUrlFields="clientID" DataNavigateUrlFormatString="Cli

Image In Gridview!

1- How can i upload and show an image file for the customer in his account details page when the information are showing to him by  a gridview?2- What is most commonly use as a data control for customer account pages (gridview or detailsview)?Regards.

display image in gridview - unlucky with tutorials

I'm trying to display images in a gridview, but after following the examples of maybe 7 different tutorials I still haven't succeded. There are always some things that go unexplained. My latest attempt is according to this tutorial:http://www.aspdotnetcodes.com/Insert_Images_Database.aspxProblem No1: what exactly should I write in my ashx-file? Following the example in the tutorial this is the code so far:<%@ WebHandler Language="C#" Class="ImageHandler" %> using System; using System.Web; using System.Configuration; using System.Data.SqlClient; public void ProcessRequest (HttpContext context) { SqlConnection myConnection = new SqlConnection("DBPejganConnectionString1"); myConnection.Open(); string sql = "Select Image_Content, Image_Type from ImageGallery where Img_Id=@ID"; SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.Parameters.Add("@ID", SqlDbType.Int).Value = context.Request.QueryString["id"]; cmd.Prepare(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); context.Response.ContentType = dr["BildTyp"].ToString(); context.Response.BinaryWrite((byte[])dr["BildData"]); dr.Close(); myConnection.Close(); }Please give me a hint (or rather the answer) on what's missing. The rest of the problems comes later... :)

Up Down GridView Icon Image for Column Sorting

I'm trying to add an Ascending and Descending sort direction Icon Image next to the header text of my ASP.NET 2.0 Gridview Columns.I've searched and found some examples that seem to do this but have had difficult time recoding them from C# to VB or some just seemed overly complex for what I want to do.Does anyone have a simple VB solution for sort icons?Thanks,Ethan   

Alert not working when used with image inside gridview

I am currently using following code to set alert on required column of my grid. When I change button type to Image the alert appear after completion action. Any quick suggestion??   My code is below.. protected void grdDelTempList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[6].Attributes.Add("onClick", "javascript:return confirm('Are You Sure?');"); } }    

Dynamic Image Buttons in GridView not doing partial post back

Hi Gurus - Create a gridview with AllowPaging and AllowSorting = true- On page load, I bind it to datasource (in my case a webservice) - On gridview's rowcreated event, I dynamically add image buttons on the header of the grid for sorting (up/down arrows). On header I have column name and the image. I removed the Column name default sorting link. So user can now only click the image button for sorting.-  Call sorting method This works perfectly fine without AJAX. The paging, sorting works fine. Also when I apply AJAX the paging works fine. But the sorting is doing a full post back instead of partial postback. I have my gridview within UpdatePanel and Triggeres is set on gridview sill it doesn't work.ASPX Code<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Label ID="lblAccount" runat="server" Text="Account #: "></asp:Label> <asp:TextBox ID="txtAccountNumber" runat="server">12203A30</asp:TextBox> <asp:Button ID="cmdGo" runat="server" Text="Go" OnClick="cmdGo_Click" /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> &l

Resize image

Hello, am writing code for upload image file and save it into disc ,,, during this and before save it to disc I want to resize the image into specified width and Heigh  am trying to use this code if (this.IsValid && this.FileUpload1.HasFile) { //Create an ImageElement to wrap up the uploaded image Neodynamic.WebControls.ImageDraw.ImageElement uploadedImage; uploadedImage = Neodynamic.WebControls.ImageDraw.ImageElement.FromBinary(this.FileUpload1.FileBytes); //Create Resize imaging action to apply on the uploaded image //NOTE: You may apply any of the ImageDraw built-in imaging actions Neodynamic.WebControls.ImageDraw.Resize actResize = new Neodynamic.WebControls.ImageDraw.Resize(); actResize.Width = 150; actResize.LockAspectRatio = Neodynamic.WebControls.ImageDraw.LockAspectRatio.WidthBased; uploadedImage.Actions.Add(actResize); //Composite the output image by using ImageDraw class Neodynamic.WebControls.ImageDraw.ImageDraw imgDraw = new Neodynamic.WebControls.ImageDraw.ImageDraw(); //Add uploaded image imgDraw.Elements.Add(uploadedImage); //Now, save the output image on disk string fileName = @"../images/" + System.IO

problems displaying image in GridView

That's right, it's me again! For the third or fourth time around I'm trying to make this work... I want to display images in a Gridview, but I'm stuck at getting the images to display. The GridView shows only the image ID:s.My images are saved in the database as <Binary Data>. I'm using an aspx page as Image Handler that receives the binary data of the image from the database and writes it to a response stream (at least that's what the tutorial says I'm doing), and the I use an Image Control in Template field on GridView to call the handler. I've been following this tutorial, and also Mudassar Khans prevoius tutorials combined with other tutorials:http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspxThankful for help!Here's my code,Imagehandler: protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] != null) { string sql = "SELECT ImgData, ImgContType from" + " BildProd where id=@id"; String strConnString = System.Configuration.ConfigurationManager .ConnectionStrings["DBPejganConnectionString1"].ConnectionString; SqlCommand cmd = new SqlCommand(sql); cmd.Parameters.Add("@id", SqlDbType.Int).Value

image resize according to user options

i want to provide user to select images to upload, maximum images is 4.the overall size is 1024px width and 500px height.within this 4 or 3 or 2 images will have to fit.if the user upload 4 images it has to calculate the overall width and height and resize the 4 images as equal width and height for each.if the user upload 2 images it has to calculate the overall width & height and fits.i want to do through code. iam using c# asp.netif any samples plz provide me.

resize image

Image img = Image.FromFile(this.tbPic1.Text.ToString()); Clipboard.SetImage(img); richtextbox1.SelectionStart = 0; rtbrichtextbox1Paste(); Clipboard.Clear(); i can insert picture to richtextbox,but how can i set the width and heigh of the picture before paste into richtextbox. one more question i would like to ask about image in MS Access Database how can i store the image into database using ODBC

Gridview resize picture Imagefield

I have Gridview and I am trying resize picture in my Imagefield goes well when i go bigger then size of pictures, when I go less then size of picture it ignore my height ,width and pictures shows the regular size. any help? thanks

Image to appear in gridview if two other gridview fields meet condition

Hi all-I'm populating a gridview with this query:Dim DataForGridview = (From p In Products _                        Join a In customerCategoryA On p.productID Equals a.productID _                        Join b In customerCategoryB On p.productID Equals b.productID _                        Select New With _                                { _                                .Product = p.product, _                            &
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend