I got this tutorial from a text book.
Instead of doing it in sql server, I am tring to do it using MS access.
After changing every thing, I found that the delete record link button will not work.
There is no compiling error of any sort.
Please help!!
Thanks
****************heres the code************************
**************Heres the html**********************
[edit]Please use
Instead of doing it in sql server, I am tring to do it using MS access.
After changing every thing, I found that the delete record link button will not work.
There is no compiling error of any sort.
Please help!!
Thanks
****************heres the code************************
Code:
Sub MyDG_ItemCommand(ByVal Sender As Object, ByVal e As DataGridCommandEventArgs)
If e.CommandSource.CommandName = "RemoveFromCat" Then
Identify the Cell that Contain the CatID
Dim CatIDCell As TableCell = e.Item.Cells(1)
Dim CatID As String = CatIDCell.Text
Dim CatThumbCell As TableCell = e.Item.Cells(4)
Dim CatThumb As String = CatThumbCell.Text
Dim CatImageCell As TableCell = e.Item.Cells(3)
Dim CatImage As String = CatImageCell.Text
USe SQL to remove the Cat with CatID = CatIDCell
dim dbconn,sql, dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" _
& "data source=" & server.mappath("..\TaraStore.mdb"))
dbconn.Open()
sql="DELETE FROM Categories WHERE CategoryID =" & CatID
dbcomm=New OleDbCommand(sql,dbconn)
dbread=dbcomm.ExecuteNonQuery()
MyDG.DataSource=dbread
MyDG.DataBind()
dbread.Close()
dbconn.Close()
Page.DataBind()
Find path to image folder
Dim strFilePath As String
strFilePath = System.IO.Path.GetDirectoryName(Server.MapPath("DeletCat.aspx"))
Delete Image
System.IO.File.Delete((strFilePath & "\..\" & "images" & "\" & CatImage))
Delete Thumbnail
System.IO.File.Delete((strFilePath & "\..\" & "images" & "\" & CatThumb))
Else
End If
Page.DataBind()
End Sub
**************Heres the html**********************
Code:
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="MyDG" style="Z-INDEX: 101; LEFT: 17px;
POSITION: absolute; TOP: 80px" runat="server"
AutoGenerateColumns="False" DataKeyField="CategoryID"
Font-Names=" Verdana" HeaderStyle-
BackColor="#aaaadd" Font-Size="8pt" Font-Name="
Verdana" CellPadding="3" BorderWidth="1px" BorderColor="Black">
<HeaderStyle backcolor="LightSteelBlue"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Select a Task">
<ItemTemplate>
<asp:LinkButton ID="RemoveButton" CommandName="RemoveFromCat" Text="Delete" ForeColor="Blue" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="CategoryID" SortExpression="CategoryID" HeaderText="Category ID"></asp:BoundColumn>
<asp:BoundColumn DataField="CategoryName" SortExpression="CategoryName" HeaderText="Category Name"></asp:BoundColumn>
<asp:BoundColumn DataField="CatImage" SortExpression="CatImage" HeaderText="Image"></asp:BoundColumn>
<asp:BoundColumn DataField="Thumbnail" SortExpression="Thumbnail" HeaderText="Thumbnail"></asp:BoundColumn>
<asp:BoundColumn DataField="Description" SortExpression="Description" HeaderText="Description"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
Code:
tags [/vb ] [/edit]
Last edited by a moderator: