.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

how to delete more than 1 image in gridview ??

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net



I have  a gridview on my page which is bound to an objectdatasource that gets Data from an Images Table in my database.


The delete button is enabled and I have this code in my DAL.


DELETE FROM [Images] WHERE (([ImageId] = @ImageId))


Instead of deleting just 1 image, I want to give a user the option to delete multiple images at once.


Any code showing how to do this in c sharp be  grateful.






View Complete Post

More Related Resource Links

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Add, Edit, update, Delete gridview

The article Add, Edit, update, Delete gridview was added by anjankant on Friday, July 09, 2010.

Thousandas operation we can do on Gridview control. Here I as explaining how we can add new recored and edit of existing record and delete a record in Gridview. Step1 : You can add this gridview in your aspx form. Here some events of Gridview are fired

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 .


Edin, New and Delete buttons in gridview?


Hi guys. I have gried view that shows me all info from the table i made. So my SelectCommand works fine. I'v add 3 additional buttons "new", "edit" and "delete" i'v made their query but still have mistake by clicking it in browser. I follow from the book Begginer to Novice 3.5 ASP C# but that's what it's shown. I know something missing. I'v check in the net but not found how to fixed, because i use SqlDataSource. Can you advise how to proceed from here? Here's what i did:

<asp:SqlDataSource ID="SqlDataSource5" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:ThisIsMyConnection%>"


              SelectCommand = "SELECT * FROM [Resident] WHERE (([FNAME] + ' ' + [LNAME] LIKE '%' + @FANDLNAME + '%'))"


              UpdateCommand = "UPDATE Resident SET FNAME=@FNAME, LNAME=@LNAME, MobileNum=@MobileNum, HomeNum=@HomeNum, OfficeNum=@OfficeNum, FaxNum=@FaxNum WHERE FNAME=@original_FNAME AND LNA

Delete from gridview

I have read about 20 articles and I can't figure out what I have done wrong.  I am trying to delete from a gridview.  Below is the code.  Any help is appreciated. <form runat='server'> <asp:SqlDataSource  ID='dsTest'  Runat='server'  ConnectionString="<%$ ConnectionStrings:myCnn %>"  SelectCommand="SELECT [ID], [Name], [Enabled], [FavoriteColor] FROM tblTest"  UpdateCommand="UPDATE tblTest SET [Name] = @Name, [Enabled] = @Enabled, [FavoriteColor] = @FavoriteColor WHERE ID = @ID"  DeleteCommand="DELETE FROM tblTest WHERE ID = @ID">  <DeleteParameters>   <asp:Parameter    name="ID" />  </DeleteParameters> </asp:SqlDataSource> <asp:GridView  ID="gvTest"  Runat='server'  DataKeyNames='ID'  AutoGenerateColumns='true'  AutoGenerateEditButton='true'  AutoGenerateDeleteButton='true'  DataSourceID="dsTest" /></form>Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@ID'.

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

Problem with "Edit" and "Delete" buttons in gridview!

Hi everyone. I have problem with the buttons Edit and Delete in Gridview for very long time and i really need help about it. So i have gridview and sqldatasource. First i try to make this buttons manually and as you will see in sqldatasource 5 and 6 i have these buttons my records show up but the buttons not working. After that i was advised to do it automatically with gridview smart tag options and Generate columns - this is what i did in sqldatasource7 and gridview7. But both ways i need to change the statements with my own because that what they create not works. So select statement works. Now the error that i get in both ways is the same:The GridView 'GridView(the number could be 5,6 or 7)' fired event RowEditing which wasn't handled.See how looks my page:Now here's my code in aspx:<%@ Page Language="C#" Title="Specific Search in Phone Directory" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="serv

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.

Can not set delete up at GridView

Hello:I am trying to add delete, update function to the gridview.After set up sqldatasource, configure the select statement, click next, it showed: test query, then finish.I did not get Advanced SQL generation Optionson the Configure the select statement, there is Advanced button at the right side. However, I clicked, it showed: Advanced SQL Generation Options, but it is disabled.How to enable Advanced SQL Generation Options so that I could set up delete, update etc functions.I am usingMicrosoft visual studio 2005Versioin 8.0.50727.762 (SP.050727-7600)Your help is highly appreciated.

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... :)

grid view image delete problem

i have a grid in which i am showing a record with image, when user delete the record the image also deleted and when it again enter the record it upload the new image but display the deleted image from the cache example: name.jpeg upload, then deleted, a different file with the name.jpeg upload, it showing the deleted one. 

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   

Gridview and delete option - Button click displays message

Hi, I have a gridview connected to a sql database that allows the user to delete the record. I used the ASP.net automatic "options" for this. However, I would like when the user deletes a record, a message (textbox) appears in the form to say the record has been deleted. Please can anyone provide some sample codes?   Thanks in advance. Nijojo.

How to delete an image file assigned to a PictureBox xontrol ?

In a Windows form application, some image files are assigned to PictureBox controls. I am trying to delete those image files. The first approach [1] with "Image.FromFile" gives an error message of "Another process is using this image file", although "Image.Dispose()" is executed. The second approach [2] using "Image.FromStream" results (X) images for PictureBoxes and Buttons, if "fs.Close()" is inclided. Without "fs.Close()", it gives the same error message of "Another process is using...". How can I display images properly and delete those images files ? Thanks [1] pictureBoxSelected.Image = Image.FromFile(@actualImage); . . . pictureBoxSelected.Image.Dispose(); pictureBoxSelected.Image = Image.FromFile(@tempImage);                                                if (System.IO.File.Exists(actualImage) == true) {     System.IO.File.Delete(actualImage); } [2] FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); pictureBox.Image = System.Drawing.Image.FromStream(fs); fs.Close();
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