Solved

Trying to delete a file that's in use

Posted on 2010-11-11
21
658 Views
Last Modified: 2012-05-10
I have some simple code that's basically loading data into a dataset and the databound handler does a resize on the image.

This code also has a database delete query and a file delete.

When the code executes for the file to be deleted, the image that's loaded on the web page, in the grid,  throws an error

"Access to the path 'D:\InetPub\ReefJunkies\Users\ganjaman\Corals\Pict ure\20080827123704lobophytum388wfsmall.jpg' is denied."

I'm not using an image stream or anything like that. It seems like the dataset is locking the file.

I'm using the obout.com grid so it's a little different. there is no item_deleting. instead it's deletecommand

Here is the code

line 187 is where it blows up

1.  
   2.  
   3. Aspx page
   4.  
   5.  
   6. <table border="0" cellpadding="0" cellspacing="0" width="100%">
   7.         <tr>
   8.             <td style="background-image: url(/Images/Blk_Grd_Bg.jpg); width: 100%; height: 20px;
   9.                 background-color: #000000">
  10.                 <span class="ArialWhite12BLD">&nbsp;</span>
  11.             </td>
  12.         </tr>
  13.         <tr>
  14.             <td align="center" style="width: 100%" valign="top">
  15.  
  16.  
  17.  
  18. <div style="margin: 0px 7px 7px" >  </div>
  19.                         <div>
  20.                         <table width="100%">
  21.                                                 <tr>
  22.                                                     <td>
  23.                                                     <div style="margin: 3px; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: large; font-weight: bold; padding-left: 20px;">
  24.                                    My Corals
  25.                                                         <asp:Label ID="LabelFilter" runat="server" ForeColor="Blue" />
  26.                                                     </div>
  27.                                                     </td>
  28.                                                     <td align="right"><div style="padding-right: 30px">
  29.                                                         <asp:LinkButton ID="LinkButtonAddCorals" runat="server" text="Add Corals" /></div></td>
  30.                                                 </tr>
  31.                                             </table> </div>
  32.  
  33.                                      <obout:Grid ID="GridMyCorals" runat="server" AllowFiltering="false" 
  34.                                                    AutoGenerateColumns="False" FolderStyle="/Images/Grid/styles/black_glass" 
  35.                                                    Width="612px" AllowAddingRecords="False" 
  36.                                           EnableRecordHover="True" AllowGrouping="True" DataKeyNames="CoralsID"
  37.                             Serialize="False"  DataSourceID="ObjectDataSourceCorals" >
  38.                                    <ClientSideEvents OnBeforeClientDelete="GridMyCorals_Deleting" />      
  39.                                          <Columns>
  40.  
  41.                                          <obout:Column ID="CoralsID" runat="server" DataField="CoralsID" HeaderText="  " width="1" Visible="false" />
  42.                                            <obout:Column ID="Picture" runat="server" DataField="Picture" HeaderText="  " width="1" Visible="false" />
  43.                                            <obout:Column ID="PictureThumb" runat="server" DataField="PictureThumb" HeaderText="  " width="1" Visible="false" />
  44.  
  45.                                              <obout:Column ID="CoralsID2" runat="server" DataField="UserAccountsID,CoralsID" 
  46.                                                  HeaderText="  " TemplateID="CoralsIDUserIdTemplate" width="170"/>
  47.  
  48.                                              <obout:Column  ID="Corals" runat="server" AllowDelete="true"
  49.                                                  TemplateID="Coralstemplate" Width="800%" DataField="CoralsID, MembersCoralName, Corals, CoralGenus, CoralGenusID, CoralType, CoralTypeID, CoralSpecies, CoralSpeciesID,  Description, datestamp, UserAccountsID, NickName, CoralAvailability, Price, UserRating" 
  50.                                                  HeaderText="Corals" Align="left" />
  51.  
  52.  
  53.  
  54.  
  55.                                              <obout:Column ID="ViewCorals" DataField="Corals, Picture, PictureThumb" HeaderText="View Reviews" Width="150" runat="server" templateid="ViewCoralstemplate" />
  56.  
  57.  
  58.                                          </Columns>
  59.                                          <Templates>
  60.                                              <obout:GridTemplate ID="Coralstemplate" runat="server">
  61.                                                  <Template>
  62.  
  63.                                                       <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItem("MembersCoralName")%>' Font-Size="Medium" /><br />
  64.  
  65.  
  66.  
  67.                                                         <div style="padding: 6px 6px 6px 0px; text-align: left;"><%# Left(Container.DataItem("Description"), 200) & "..."%></div>
  68.                                                         <b>Availability:</b> &nbsp;<%# GetAvailabilityFormat(Container.DataItem("CoralAvailability"))%>&nbsp;&nbsp;<b>Price:</b> &nbsp;$<%# Container.DataItem("Price")%>&nbsp;&nbsp; <br /> <b>Rating:</b> &nbsp;<%# GetRatingFormat(Container.DataItem("Rating"))%><br /><b><%# FormatDateTime(Container.DataItem("DateStamp") & "", DateFormat.LongDate)%></b><hr noshade="noshade" align="left" color="#CCCCCC" /><b>Type:</b>&nbsp;<asp:HyperLink ID="HyperLinkCoralType" runat="server" Text='<%# Container.DataItem("CoralType")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?CoraltypeID=" & Container.DataItem("CoralTypeID")%>' />&nbsp;&nbsp;<b>Genus:</b>&nbsp;<asp:HyperLink ID="HyperLinkGenusType" runat="server" Text='<%# Container.DataItem("CoralGenus")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?GenustypeID=" & Container.DataItem("CoralGenusID")%>' />&nbsp;&nbsp;
  69.                                                      <br /><b>Species:</b> &nbsp;<asp:HyperLink ID="HyperLinkSpecies" runat="server" Text='<%# Container.DataItem("CoralSpecies")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?SpeciestypeID=" & Container.DataItem("CoralSpeciesID")%>' />
  70.                                                      <br />
  71.                                                      <table>
  72.                                                         <tr>
  73.                                                             <td> <asp:HyperLink ID="HyperLinkEdit" runat="server" text="Edit" NavigateUrl='<%# "/Corals/AddEditCoral.aspx?ID=" & Container.DataItem("CoralsID")%>' BorderColor="Black" BorderStyle="Solid" BorderWidth="1"><img src="/Images/ButtonEdit.jpg" /></asp:HyperLink> </td>
  74.                                                             <td> <img src="/Images/ButtonDelete.jpg" onclick="GridMyCorals.delete_record(this);"  border="1" style="border: 1px solid #000000" />
  75.  
  76.  
  77.                                                         </tr>
  78.                                                      </table>
  79.  
  80.  
  81.                                                  </Template>
  82.                                              </obout:GridTemplate>
  83.  
  84.  
  85.                                               <obout:GridTemplate ID="ViewCoralstemplate" runat="server">
  86.                                                  <Template>
  87.  
  88.  
  89.  
  90.                                                      <asp:Hyperlink ID="Imageicon" runat="server" Width="50" alt="View Details" NavigateUrl='<%# "/Corals/CoralDetails.aspx?ID=" & Container.DataItem("CoralsID")%>'><img src="/images/icons/fish.png" width="90" /></asp:Hyperlink>
  91.  
  92.  
  93.  
  94.                                                  </Template>
  95.                                              </obout:GridTemplate>
  96.                                              <obout:GridTemplate ID="CoralsIDUserIdTemplate" runat="server">
  97.                                                  <Template>
  98.                                                  <div style="padding: 6px; border: 1px solid #666666; text-align: center; background-color: #DEDEDE; background-image: url('/Images/Grey_Gradient_profile_bg.jpg');">
  99.  
 100.                                                      <obout:ImageZoom ID="ImageZoomPort" runat="server" StyleFolder="/Images/Imagezoom/Styles/dark" BorderColor="Black" BorderStyle="Solid" BorderWidth="1" />
 101.  
 102.                                                     <br />
 103.  
 104.                                                      <asp:HiddenField ID="HiddenUserID" runat="server" Value='<%# Container.DataItem("UserAccountsID") %>' />
 105.                                                      <asp:HiddenField ID="HiddenCoralsID" runat="server" Value='<%# Container.DataItem("CoralsID") %>' />
 106.                                                     <asp:HiddenField ID="HiddenPicture" runat="server" Value='<%# Container.DataItem("Picture")%>' />
 107.                                                  <asp:HiddenField ID="HiddenPictureThumb" runat="server" Value='<%# Container.DataItem("PictureThumb")%>' />
 108.                                                  </div>
 109.                                                  </Template>
 110.                                              </obout:GridTemplate>
 111.  
 112.                                          </Templates>
 113.                                      </obout:Grid>
 114.  
 115.  
 116.  
 117.  
 118.  
 119.  
 120.  
 121.  
 122.                                      <asp:ObjectDataSource ID="ObjectDataSourceCorals" 
 123.                      runat="server" SelectMethod="GetCoralsByUser" TypeName="DAL" DeleteMethod="DeleteCoral" >
 124.                                          <DeleteParameters>
 125.                                              <asp:Parameter Name="CoralsID" Type="Int32" />
 126.                                          </DeleteParameters>
 127.                                          <SelectParameters>
 128.                                               <asp:SessionParameter Name="UserAccountsID" SessionField="UserAccountsID" 
 129.                                                   Type="Int32" />
 130.                                          </SelectParameters>
 131.                  </asp:ObjectDataSource> 
 132.  
 133.  
 134.  
 135.  
 136.  
 137.  
 138.  
 139.  
 140.  
 141.                                      <br />
 142.  
 143.                    </td>
 144.         </tr>
 145.     </table>
 146.  
 147.  
 148.  
 149.  
 150. .vb page
 151.  
 152. Imports Obout.Grid
 153. Imports OboutInc.ImageZoom
 154. Imports System.IO
 155.  
 156. Partial Class Corals_MyCorals
 157.     Inherits System.Web.UI.Page
 158.  
 159.     Dim Dal As New DAL
 160.  
 161.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 162.  
 163.         Dim Script As String = "function GridMyCorals_Deleting(sender) {" & _
 164. " return confirm('Are you sure you want to delete this Coral?');" & _
 165. " } "
 166.  
 167.         Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "Script", Script, True)
 168.  
 169.     End Sub
 170.  
 171.     Protected Sub GridMyCorals_DeleteCommand(ByVal sender As Object, ByVal e As Obout.Grid.GridRecordEventArgs) Handles GridMyCorals.DeleteCommand
 172.  
 173.         'ObjectDataSourceCorals.Dispose()
 174.         'GridMyCorals.Dispose()
 175.  
 176.  
 177.         Dim Picture = e.Record("Picture")
 178.         Dim PictureThumb = e.Record("PictureThumb")
 179.  
 180.         Dim fd1 As New FileInfo(Server.MapPath("/" & Application("SysUserDir") & "/" & Picture))
 181.         If fd1.Exists = True Then
 182.             fd1.Delete()
 183.         End If
 184.  
 185.         Dim fd2 As New FileInfo(Server.MapPath("/" & Application("SysUserDir") & "/" & PictureThumb))
 186.         If fd2.Exists = True Then
 187.             fd2.Delete()
 188.         End If
 189.  
 190.         Dim CoralsID = e.Record("CoralsID")
 191.         Dal.DeleteCoral(CoralsID)
 192.  
 193.  
 194.     End Sub
 195.  
 196.     Protected Sub GridMyCorals_RowDataBound(ByVal sender As Object, ByVal e As Obout.Grid.GridRowEventArgs) Handles GridMyCorals.RowDataBound
 197.  
 198.         If e.Row.RowType = GridRowType.DataRow Then
 199.  
 200.             Dim cell As GridDataControlFieldCell = CType(e.Row.Cells(3), GridDataControlFieldCell)
 201.             Dim CoralsID = CType(cell.FindControl("HiddenCoralsID"), HiddenField).Value
 202.             Dim UserAccountsID = CType(cell.FindControl("HiddenUserID"), HiddenField).Value
 203.  
 204.  
 205.             Dim Picture = CType(cell.FindControl("HiddenPicture"), HiddenField).Value
 206.             Dim PictureThumb = CType(cell.FindControl("HiddenPictureThumb"), HiddenField).Value
 207.  
 208.  
 209.  
 210.             If IsDBNull(Picture) Or IsNothing(Picture) Or Picture = "" Then
 211.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).ImageUrl = "/Images/NoPhoto.jpg"
 212.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).Width = "125"
 213.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).BigImageUrl = "/Images/NoPhotoLarge.jpg"
 214.             Else
 215.                 'Dim RecentMembersThumb = Dal.GetProfilePicture(UserID)
 216.                 'scale Picture-----------------------------------------------------
 217.  
 218.                 Dim ImageScale As New ImageScale
 219.  
 220.                 ImageScale.MaxWidth = 125
 221.                 ImageScale.MaxHeight = 125
 222.  
 223.                 ImageScale.PictureThumbLocation = "/" + Application("SysUserDir") + PictureThumb
 224.  
 225.                 ImageScale.ImageScaler()
 226.  
 227.                 'End Scale-------------------------------------------------------
 228.  
 229.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).ImageUrl = "/" + Application("SysUserDir") + PictureThumb
 230.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).BigImageUrl = "/" + Application("SysUserDir") + Picture
 231.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).Width = ImageScale.ScaledImageWidth
 232.                 CType(cell.FindControl("ImageZoomPort"), ImageZoom).Height = ImageScale.ScaledImageHeight
 233.  
 234.                 Picture = Nothing
 235.                 PictureThumb = Nothing
 236.  
 237.             End If
 238.  
 239.         End If
 240.  
 241.     End Sub
 242.  
 243.     Function GetAvailabilityFormat(ByVal CoralAvailability As String) As String
 244.  
 245.         If CoralAvailability = "Now" Then
 246.             Return "<Font color=#006600>Now</font>"
 247.         ElseIf CoralAvailability = "Soon" Then
 248.             Return "<Font color=#996600>Soon</font>"
 249.         End If
 250.  
 251.  
 252.  
 253.     End Function
 254.  
 255.     Function GetRatingFormat(ByVal userRating As Object) As String
 256.         Dim decimalRating As Decimal = Nothing
 257.  
 258.         If TypeOf userRating Is Decimal Then
 259.             decimalRating = DirectCast(userRating, Decimal)
 260.         ElseIf IsNumeric(userRating) Then
 261.             decimalRating = CDec(userRating)
 262.         End If
 263.  
 264.         If decimalRating = Nothing Then
 265.             Return ("Not Yet Rated")
 266.         Else
 267.             Return (Format(decimalRating, "0.0") & "%")
 268.         End If
 269.  
 270.     End Function
 271.  
 272.     Protected Sub LinkButtonAddCorals_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonAddCorals.Click
 273.  
 274.         Response.Redirect("/Corals/AddEditCoral.aspx")
 275.  
 276.     End Sub
 277.  
 278.  
 279. End Class
 280.  
 281.  
 282.

Open in new window

0
Comment
Question by:TheWebGuy38
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 7
21 Comments
 
LVL 21

Expert Comment

by:Alfred1
ID: 34117897
Try the following:

1.  Set read/write privileges to your virtual folder in IIS.

2.  Also, try to allow or provide permission for ASPNET user to change the content of the physical folder in your file system.
0
 

Author Comment

by:TheWebGuy38
ID: 34117952
If I use the formview, the file deletes with the same code. it's just in the grid control.
so I don't think it's a permissions issue :(
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34118127
OK.  Maybe the file is read only.  You can try improving your code by doing something like this.
If fd2.Exists = True Then
    fd2.SetAttributes(fileName, FileAttributes.Normal)
    fd2.Delete()
End If

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TheWebGuy38
ID: 34118184
Your code didn't work because fd2 was fileinfo. So I moded it. not sure if it's right. but it didn't work.same problem. here is my code

 Dim PathPicture = Server.MapPath("/" & Application("SysUserDir") & "/" & Picture)
        If fd2.Exists = True Then
            Dim file As File
            file.SetAttributes(PathPicture, FileAttributes.Normal)
            fd2.Delete()
        End If
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34118236
I guess there is a process locked to the file at the point of delete.  Try using Process Explorer (www.sysinternals.com) to find the handler of this process.

http://technet.microsoft.com/en-gb/sysinternals/bb896653.aspx
0
 

Author Comment

by:TheWebGuy38
ID: 34118267
I'm pretty sure it's the obout.com grid that's using the file

you can see the live code at
http://www.reefjunkies.org/Aquariums/Default.aspx

login: bill
pass: bill

I will see what process is using it in the meantime
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34118288
If the grid is the one locking the file, maybe you need to remove references to the file in the grid before deleting.

Try to remove all references to file from the grid, and then try to delete it.  You can try redirecting the reference to another image for example before deleting.
0
 

Author Comment

by:TheWebGuy38
ID: 34118311
You kinda lost me. what do you mean by removing the references?
0
 

Author Comment

by:TheWebGuy38
ID: 34118370
disregard last post. lol, I'm tired.

OK, interesting. I removed the image from loading in the grid. when I delete it. I still get the same error.
maybe it's not the grid. hrmmmm
0
 

Author Comment

by:TheWebGuy38
ID: 34118372
OOOPS! missed a reference.  Yes, it is the grid. sigh
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34118547
So, did it work? I mean did you manage to delete the file after removing references to it?
0
 

Author Comment

by:TheWebGuy38
ID: 34118598
Yes, that is correct. Once I moved the references for Picture, and Picturethumb in the grid. The delete code worked fine. So it's the Grid that is using the process.:(
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34119520
I guess that solves your access denied issue.  :-)

You only need to provide logic in the use and deletion of images in your website.
0
 

Author Comment

by:TheWebGuy38
ID: 34125900
Now I'm completely confused.
I just simplified the code and put it in an access database.
the code seems to work fine.

the only real difference is that aside from being simplified, it's access instead of sql.
Can SQL be locking the file?
0
 

Author Comment

by:TheWebGuy38
ID: 34125920
OK, so I used this code with a sqldatasource and it works. not sure why this code works and my other code doesn't . here is the code
ASPX page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:Grid ID="Grid1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" Width="600" DataKeyNames="ID">

        <Columns>
        <cc1:Column ID="Image" runat="server" DataField="Image" HeaderText="Image" width="400" Visible="true" TemplateID="template" />
         <cc1:Column ID="delete" runat="server"  HeaderText="Delete" width="400" Visible="true" TemplateID="templatedelete" allowdelete="true"/>
        
        
        </Columns>
        <Templates>
           <cc1:GridTemplate ID="template" runat="server">
            <Template>
                <asp:Image ID="Image1" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1" />
                 <asp:HiddenField ID="HiddenPicture" runat="server" Value='<%# Container.DataItem("Image")%>' />
            </Template>
           </cc1:GridTemplate>
        <cc1:GridTemplate ID="templatedelete" runat="server">
            <Template>
            <img src="Images/ButtonDelete.jpg" onclick="Grid1.delete_record(this);"  border="1" style="border: 1px solid #000000" />
                                                      
            </Template>
        </cc1:GridTemplate>
   
        </Templates>


        </cc1:Grid>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/Database1.accdb" 
            SelectCommand="SELECT * FROM [Table1]" 
            DeleteCommand="DELETE FROM Table1 WHERE (ID = @ID)"></asp:AccessDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ReefJunkiesConnectionString %>" 
            SelectCommand="SELECT * FROM [Table1]"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>



.vb page

Imports System.IO
Imports Obout.Grid

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Grid1_DeleteCommand(ByVal sender As Object, ByVal e As Obout.Grid.GridRecordEventArgs) Handles Grid1.DeleteCommand

        Dim Image = e.Record("Image")

        Dim fd1 As New FileInfo(Server.MapPath(Image))
        If fd1.Exists = True Then
            fd1.Delete()
        End If



    End Sub

    Protected Sub Grid1_RowDataBound(ByVal sender As Object, ByVal e As Obout.Grid.GridRowEventArgs) Handles Grid1.RowDataBound

        If e.Row.RowType = GridRowType.DataRow Then

            Dim cell As GridDataControlFieldCell = CType(e.Row.Cells(0), GridDataControlFieldCell)
            'Dim cell2 As GridDataControlFieldCell = CType(e.Row.Cells(2), GridDataControlFieldCell)




            Dim Picture = CType(cell.FindControl("HiddenPicture"), HiddenField).Value




            If IsDBNull(Picture) Or IsNothing(Picture) Or Picture = "" Then
                CType(cell.FindControl("Image1"), Image).ImageUrl = "/Images/NoPhoto.jpg"
                CType(cell.FindControl("Image1"), Image).Width = "125"
                ' CType(cell.FindControl("Image1"), Image).BigImageUrl = "/Images/NoPhotoLarge.jpg"
            Else
                'Dim RecentMembersThumb = Dal.GetProfilePicture(UserID)
                'scale Picture-----------------------------------------------------

                Dim ImageScale As New ImageScale

                ImageScale.MaxWidth = 125
                ImageScale.MaxHeight = 125

                ImageScale.PictureThumbLocation = Picture

                ImageScale.ImageScaler()

                'End Scale-------------------------------------------------------

                CType(cell.FindControl("Image1"), Image).ImageUrl = Picture
                'CType(cell.FindControl("Image1"), Image).BigImageUrl = "/" + Application("SysUserDir") + Picture
                CType(cell.FindControl("Image1"), Image).Width = ImageScale.ScaledImageWidth
                CType(cell.FindControl("Image1"), Image).Height = ImageScale.ScaledImageHeight

              

            End If

        End If


    End Sub
End Class

Open in new window

0
 

Author Comment

by:TheWebGuy38
ID: 34126061
Found the problem. thinnk it's a glitch in the grid because I have no idea why this does it but the code started working when I removed

Line 41, and line 42


  <obout:Column ID="Picture" runat="server" DataField="Picture" HeaderText="  " width="1" Visible="false" />
                                           <obout:Column ID="PictureThumb" runat="server" DataField="PictureThumb" HeaderText="  " width="1" Visible="false" />



<%@ Page Title="" Language="VB" MasterPageFile="~/Templates/Main.Master" AutoEventWireup="false" CodeFile="MyCorals.aspx.vb" Inherits="Corals_MyCorals" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server">

<table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td style="background-image: url(/Images/Blk_Grd_Bg.jpg); width: 100%; height: 20px;
                background-color: #000000">
                <span class="ArialWhite12BLD">&nbsp;</span>
            </td>
        </tr>
        <tr>
            <td align="center" style="width: 100%" valign="top">

            
             
<div style="margin: 0px 7px 7px" >  </div>
                        <div>
                        <table width="100%">
                                                <tr>
                                                    <td>
                                                    <div style="margin: 3px; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: large; font-weight: bold; padding-left: 20px;">
                                   My Corals
                                                        <asp:Label ID="LabelFilter" runat="server" ForeColor="Blue" />
                                                    </div>
                                                    </td>
                                                    <td align="right"><div style="padding-right: 30px">
                                                        <asp:LinkButton ID="LinkButtonAddCorals" runat="server" text="Add Corals" /></div></td>
                                                </tr>
                                            </table> </div>

                                     <obout:Grid ID="GridMyCorals" runat="server" AllowFiltering="false" 
                                                   AutoGenerateColumns="False" FolderStyle="/Images/Grid/styles/black_glass" 
                                                   Width="612px" AllowAddingRecords="False" 
                                          EnableRecordHover="True" AllowGrouping="True" DataKeyNames="CoralsID"
                            Serialize="False"  DataSourceID="ObjectDataSourceCorals" >
                                   <ClientSideEvents OnBeforeClientDelete="GridMyCorals_Deleting" />      
                                         <Columns>

                                         <obout:Column ID="CoralsID" runat="server" DataField="CoralsID" HeaderText="  " width="1" Visible="false" />
                                           <obout:Column ID="Picture" runat="server" DataField="Picture" HeaderText="  " width="1" Visible="false" />
                                           <obout:Column ID="PictureThumb" runat="server" DataField="PictureThumb" HeaderText="  " width="1" Visible="false" />

                                             <obout:Column ID="CoralsID2" runat="server" DataField="UserAccountsID,CoralsID" 
                                                 HeaderText="  " TemplateID="CoralsIDUserIdTemplate" width="170"/>
                                                
                                             <obout:Column  ID="Corals" runat="server" AllowDelete="true"
                                                 TemplateID="Coralstemplate" Width="800%" DataField="CoralsID, MembersCoralName, Corals, CoralGenus, CoralGenusID, CoralType, CoralTypeID, CoralSpecies, CoralSpeciesID,  Description, datestamp, UserAccountsID, NickName, CoralAvailability, Price, UserRating" 
                                                 HeaderText="Corals" Align="left" />
                                               
                                             
                                           
                                             
                                             <obout:Column ID="ViewCorals" DataField="Corals, Picture, PictureThumb" HeaderText="View Reviews" Width="150" runat="server" templateid="ViewCoralstemplate" />
                                             
                                             
                                         </Columns>
                                         <Templates>
                                             <obout:GridTemplate ID="Coralstemplate" runat="server">
                                                 <Template>
                                                    
                                                      <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItem("MembersCoralName")%>' Font-Size="Medium" /><br />


                                             
                                                        <div style="padding: 6px 6px 6px 0px; text-align: left;"><%# Left(Container.DataItem("Description"), 200) & "..."%></div>
                                                        <b>Availability:</b> &nbsp;<%# GetAvailabilityFormat(Container.DataItem("CoralAvailability"))%>&nbsp;&nbsp;<b>Price:</b> &nbsp;$<%# Container.DataItem("Price")%>&nbsp;&nbsp; <br /> <b>Rating:</b> &nbsp;<%# GetRatingFormat(Container.DataItem("Rating"))%><br /><b><%# FormatDateTime(Container.DataItem("DateStamp") & "", DateFormat.LongDate)%></b><hr noshade="noshade" align="left" color="#CCCCCC" /><b>Type:</b>&nbsp;<asp:HyperLink ID="HyperLinkCoralType" runat="server" Text='<%# Container.DataItem("CoralType")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?CoraltypeID=" & Container.DataItem("CoralTypeID")%>' />&nbsp;&nbsp;<b>Genus:</b>&nbsp;<asp:HyperLink ID="HyperLinkGenusType" runat="server" Text='<%# Container.DataItem("CoralGenus")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?GenustypeID=" & Container.DataItem("CoralGenusID")%>' />&nbsp;&nbsp;
                                                     <br /><b>Species:</b> &nbsp;<asp:HyperLink ID="HyperLinkSpecies" runat="server" Text='<%# Container.DataItem("CoralSpecies")%>' NavigateUrl='<%# "/Corals/RecentCorals.aspx?SpeciestypeID=" & Container.DataItem("CoralSpeciesID")%>' />
                                                     <br />
                                                     <table>
                                                        <tr>
                                                            <td> <asp:HyperLink ID="HyperLinkEdit" runat="server" text="Edit" NavigateUrl='<%# "/Corals/AddEditCoral.aspx?ID=" & Container.DataItem("CoralsID")%>' BorderColor="Black" BorderStyle="Solid" BorderWidth="1"><img src="/Images/ButtonEdit.jpg" /></asp:HyperLink> </td>
                                                            <td> <img src="/Images/ButtonDelete.jpg" onclick="GridMyCorals.delete_record(this);"  border="1" style="border: 1px solid #000000" />
                                                            
                                                          
                                                        </tr>
                                                     </table>
                                                    
                                                    
                                                 </Template>
                                             </obout:GridTemplate>
                                             
                                             
                                              <obout:GridTemplate ID="ViewCoralstemplate" runat="server">
                                                 <Template>
                                                  
                                                     
                                                     
                                                     <asp:Hyperlink ID="Imageicon" runat="server" Width="50" alt="View Details" NavigateUrl='<%# "/Corals/CoralDetails.aspx?ID=" & Container.DataItem("CoralsID")%>'><img src="/images/icons/fish.png" width="90" /></asp:Hyperlink>
                                                     
                                                    

                                                 </Template>
                                             </obout:GridTemplate>
                                             <obout:GridTemplate ID="CoralsIDUserIdTemplate" runat="server">
                                                 <Template>
                                                 <div style="padding: 6px; border: 1px solid #666666; text-align: center; background-color: #DEDEDE; background-image: url('/Images/Grey_Gradient_profile_bg.jpg');">

                                                     <obout:ImageZoom ID="ImageZoomPort" runat="server" StyleFolder="/Images/Imagezoom/Styles/dark" BorderColor="Black" BorderStyle="Solid" BorderWidth="1" />

                                                    <br />
                                                  
                                                     <asp:HiddenField ID="HiddenUserID" runat="server" Value='<%# Container.DataItem("UserAccountsID") %>' />
                                                     <asp:HiddenField ID="HiddenCoralsID" runat="server" Value='<%# Container.DataItem("CoralsID") %>' />
                                                    <asp:HiddenField ID="HiddenPicture" runat="server" Value='<%# Container.DataItem("Picture")%>' />
                                                 <asp:HiddenField ID="HiddenPictureThumb" runat="server" Value='<%# Container.DataItem("PictureThumb")%>' />
                                                 </div>
                                                 </Template>
                                             </obout:GridTemplate>
                                            
                                         </Templates>
                                     </obout:Grid>


                                    
                 




                                     <asp:ObjectDataSource ID="ObjectDataSourceCorals" 
                     runat="server" SelectMethod="GetCoralsByUser" TypeName="DAL" DeleteMethod="DeleteCoral" >
                                         <DeleteParameters>
                                             <asp:Parameter Name="CoralsID" Type="Int32" />
                                         </DeleteParameters>
                                         <SelectParameters>
                                              <asp:SessionParameter Name="UserAccountsID" SessionField="UserAccountsID" 
                                                  Type="Int32" />
                                         </SelectParameters>
                 </asp:ObjectDataSource> 



                                    
                 




                                     <br />
        
                   </td>
        </tr>
    </table>



</asp:Content>

Open in new window

0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34126099
The one you found must be the ones still causing the problem.  Looking at it, it looks like it will have a reference to the image once an instance of the grid control is created.  Removing Line 41 and 42 would definitely remove the reference to the image.

Like I said before, would there be a way for you to let say redirect the contents of items referencing your image such as the columns in line 41 and 42 to a blank image for example before doing your delete?  Especially, your deletecommand event is within the grid.

By the way, have you tried using Process Explorer?  It can provide with detailed information about processes.  I suggest have a try so that you could isolate all objects that has a "business" with your image.

0
 

Accepted Solution

by:
TheWebGuy38 earned 0 total points
ID: 34126109
well what I'm doing is passing the variable in a hidden field to the code behind.
and it seems to be working.

I think it's a glitch in the control, but I have it working
0
 

Author Comment

by:TheWebGuy38
ID: 34280407
the code worked after I removed these 2 lines

  <obout:Column ID="Picture" runat="server" DataField="Picture" HeaderText="  " width="1" Visible="false" />
                                           <obout:Column ID="PictureThumb" runat="server" DataField="PictureThumb" HeaderText="  " width="1" Visible="false" />



think it's a glitch in the control
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34317308
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question