B
bdog4
I'm a bit new to asp.net and I'm trying to do very simple delete from
a grid view but everytime I click on the delete link for the row it
the page reloads and of course my row is still there. What am I
missing here?
<%@ Page Language="VB" MasterPageFile="~/XeroxScan.master"
AutoEventWireup="false" CodeFile="Files.aspx.vb" Inherits="Files"
title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
Width="719px">
<Columns>
<asp:BoundField DataField="ClientCode"
HeaderText="ClientCode" SortExpression="ClientCode" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:HyperLinkField DataNavigateUrlFields="FileID"
DataNavigateUrlFormatString="EditEntry.aspx?FileID={0}"
HeaderText="Edit" Text="Edit" />
<asp:TemplateField ShowHeader="False" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False" CommandName="Delete"
OnClientClick='return confirm("Are you sure you
want to delete this entry?");'
Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:WCMWebConnectionString1 %>"
ProviderName="<%$
ConnectionStrings:WCMWebConnectionString1.ProviderName %>"
SelectCommand="SELECT [FileID], [ClientCode], [Description],
[Client] FROM [StandFiles] ORDER BY [ClientCode]"
DeleteCommand="DELETE FROM [StandFiles] WHERE [FileID] = @FileID"
InsertCommand="INSERT INTO [StandFiles] ([ClientCode], [Description],
[Client]) VALUES (@ClientCode, @Description, @Client)"
UpdateCommand="UPDATE [StandFiles] SET [ClientCode] = @ClientCode,
[Description] = @Description, [Client] = @Client WHERE [FileID] =
@FileID">
<DeleteParameters>
<asparameter Name="FileID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="ClientCode" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Client" Type="String" />
<asparameter Name="FileID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
</SelectParameters>
<InsertParameters>
<asparameter Name="ClientCode" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Client" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
</asp:Content>
a grid view but everytime I click on the delete link for the row it
the page reloads and of course my row is still there. What am I
missing here?
<%@ Page Language="VB" MasterPageFile="~/XeroxScan.master"
AutoEventWireup="false" CodeFile="Files.aspx.vb" Inherits="Files"
title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
Width="719px">
<Columns>
<asp:BoundField DataField="ClientCode"
HeaderText="ClientCode" SortExpression="ClientCode" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:HyperLinkField DataNavigateUrlFields="FileID"
DataNavigateUrlFormatString="EditEntry.aspx?FileID={0}"
HeaderText="Edit" Text="Edit" />
<asp:TemplateField ShowHeader="False" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False" CommandName="Delete"
OnClientClick='return confirm("Are you sure you
want to delete this entry?");'
Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:WCMWebConnectionString1 %>"
ProviderName="<%$
ConnectionStrings:WCMWebConnectionString1.ProviderName %>"
SelectCommand="SELECT [FileID], [ClientCode], [Description],
[Client] FROM [StandFiles] ORDER BY [ClientCode]"
DeleteCommand="DELETE FROM [StandFiles] WHERE [FileID] = @FileID"
InsertCommand="INSERT INTO [StandFiles] ([ClientCode], [Description],
[Client]) VALUES (@ClientCode, @Description, @Client)"
UpdateCommand="UPDATE [StandFiles] SET [ClientCode] = @ClientCode,
[Description] = @Description, [Client] = @Client WHERE [FileID] =
@FileID">
<DeleteParameters>
<asparameter Name="FileID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="ClientCode" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Client" Type="String" />
<asparameter Name="FileID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
</SelectParameters>
<InsertParameters>
<asparameter Name="ClientCode" Type="String" />
<asparameter Name="Description" Type="String" />
<asparameter Name="Client" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
</asp:Content>