Unable to delete row using gridview

G

Guest

I am using ASP.Net 2.0 and have a gridview on my page. I have everything
working except the delete command. The page reloads except the row I am
trying to delete is still there. I believe it is something really easy, but I
cannot see it. The stored procedue works when run in QA. Can someone tell me
what I am doing wrong/missing that is keeping the delete command from working
in the gridview? Thank you.

I am trying to delete a row out of a line item table (ProjectLocationLI)
joining projects (projectid) and locations (locationid)

--ProjectLocationLI Table
CREATE TABLE [dbo].[ProjectLocationLI] (
[ProjectLocationLIID] [int] IDENTITY (1, 1) NOT NULL ,
[ProjectID] [int] NOT NULL ,
[LocationID] [int] NOT NULL
) ON [PRIMARY]
GO




--Gridview and datasource code

<asp:GridView ID="gvLocations" runat="server"
AutoGenerateColumns="False" CellPadding="4"
BorderColor="#5D7B9D" ForeColor="#333333" GridLines="None"
style="padding:1px; margin-top: 25px; margin-left: 10px;" Width="215px"
BorderStyle="Solid"
BorderWidth="1px"
DataKeyNames="LocationID" DataSourceID="SqlDataSource1">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ButtonType="Image"
CancelImageUrl="~/images/icons/canceledit_icon.gif"
DeleteImageUrl="~/images/icons/delete_icon.gif"
EditImageUrl="~/images/icons/edit_icon.gif" ShowEditButton="True"
UpdateImageUrl="~/images/icons/update_icon.gif" />
<asp:CommandField ButtonType="Image"
DeleteImageUrl="~/images/icons/delete_icon.gif"
DeleteText="" ShowDeleteButton="True" />
<asp:BoundField DataField="Name" HeaderText="Test Locations"
SortExpression="Name" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="LightGray" ForeColor="#284775" />
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CommonConnectionString %>"
SelectCommand="ListLocationsByProject"
SelectCommandType="StoredProcedure" DeleteCommand="DeleteLocationFromProject"
DeleteCommandType="StoredProcedure" UpdateCommand="UpdateLocation"
UpdateCommandType="StoredProcedure" InsertCommand="InsertLocation"
InsertCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="projectID" SessionField="ProjectID"
Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:parameter Name="projectID" Type="int32" />
<asp:parameter Name="locationID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="locationID" Type="Int32" />
<asp:parameter Name="name" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="name" Type="String" />
</InsertParameters>
</asp:SqlDataSource>





--Stored Procedure being used
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER PROCEDURE DeleteLocationFromProject (@projectID int, @locationID int)
AS

DELETE FROM ProjectLocationLI
WHERE ProjectID = @projectID AND LocationID = @locationID


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
 

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

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top