473,509 Members | 2,946 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help -- Gridview Not Deleting Rows

I have been trying to figure this out for days now...can someone please help?

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
Nov 22 '06 #1
0 1229

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6308
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
1
7866
by: Mike P | last post by:
When you use a SqlDataSource to hook up data to a GridView it seems to be to be very inflexible. For example, I want to create my own Delete button with my own code and I also want to create a...
6
28099
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
2
5444
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
11
2533
by: Greg | last post by:
I have a gridview on my form which I have populated using a datareader. What I would like to do is to be able to remove specified records from the gridview, without affecting the source of the...
0
4918
by: David Lozzi | last post by:
Howdy, I have a gridview with a linkbutton in a template column (code is below). When the linkbutton is clicked i want to display a little confirm right in the gridview to confirm deleting the...
0
4640
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
0
2365
by: Andy B | last post by:
I have the following gridview. There are 2 other textBoxes and a button on the page as well. When somebody puts text into the 2 textBoxes and presses the add button, it puts the values of those...
2
2295
by: =?Utf-8?B?QXN0cml0aA==?= | last post by:
I am a Newbie and i am scratching my head over how to delete a Row from a GridView. I have this GridView which has 3 fields called ID,ProjCode and ProjDescription of which ID is the hidden...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.