determine Boundfield Value during rowcommand deletion


S

sjsean

In order to delete a photo file in a directory I need to determine the
photoname...and I don't seem to be doing something right. I got
things to work in classic but am trying to upgrade to ASP.Net

errormessage: System.IO.FileNotFoundException: Exception from
HRESULT: 0x800A0035 (CTL_E_FILENOTFOUND)

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridView1.RowCommand

If e.CommandName = "Update" Then SqlDataSource1.Update()
If e.CommandName = "Delete" Then

Dim fs
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = sender.Rows(index)
Dim phname = row.Cells(2).Text
SqlDataSource1.Delete()

fs = Server.CreateObject("Scripting.FileSystemObject")

fs.DeleteFile(Server.MapPath("Practice_login/photos/" &
phname & ""))
fs = Nothing


End If


<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" Height="200px"
DataKeyNames="photoid,photoname">
<Columns>
<asp:BoundField DataField="approval"
HeaderText="approval" SortExpression="approval" />
<asp:BoundField DataField="photoid"
HeaderText="photoid" InsertVisible="False" SortExpression="photoid" />
<asp:BoundField DataField="photoname"
HeaderText="photoname" SortExpression="photoname" />
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top