473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

GridView not updating or deleting

I'm making a quick CD catalog to help me learn ASP.NET (using C# primarily.) I have a number of gridview's on my site that are working properly, but for some reason, one is not updating or deleting. I have the buttons for both visible, and when I click edit, the update fields show up properly, but once I click 'update' the table is back with it's old information. When I click 'delete' the page completes the postback properly, but once again, the information is the same.

Here is my source code for the page in question:
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="FullEditAlbumGridView" runat="server" AllowPaging="True" AllowSorting="True"
  2.         AutoGenerateColumns="False" DataSourceID="FullEditSqlDataSource" Width="717px" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True">
  3.         <FooterStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" ForeColor="Ivory" />
  4.         <Columns>
  5.             <asp:BoundField DataField="AlbumID" HeaderText="AlbumID" InsertVisible="False" ReadOnly="True"
  6.                 ShowHeader="False" SortExpression="AlbumID" Visible="False" />
  7.             <asp:TemplateField HeaderText="AlbumTitle" SortExpression="AlbumTitle">
  8.                 <EditItemTemplate>
  9.                     <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("AlbumTitle") %>'></asp:TextBox>
  10.                     <asp:RequiredFieldValidator ID="AlbumTitleValidator" runat="server" ErrorMessage="<br />Title is required" ControlToValidate="TitleTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
  11.                 </EditItemTemplate>
  12.                 <ItemTemplate>
  13.                     <asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("AlbumTitle") %>'></asp:Label>
  14.                 </ItemTemplate>
  15.             </asp:TemplateField>
  16.             <asp:TemplateField HeaderText="AlbumYear" SortExpression="AlbumYear">
  17.                 <EditItemTemplate>
  18.                     <asp:TextBox ID="YearPubTextBox" Type="Integer" runat="server" Text='<%# Bind("AlbumYear") %>'></asp:TextBox>
  19.                     <asp:RequiredFieldValidator ID="YearValidator" runat="server" ControlToValidate="YearPubTextBox" Display="Dynamic" ErrorMessage="<br />Year is a required field"></asp:RequiredFieldValidator>
  20.  
  21.                 </EditItemTemplate>
  22.                 <ItemTemplate>
  23.                     <asp:Label ID="YearPubLabel" runat="server" Text='<%# Bind("AlbumYear") %>'></asp:Label>
  24.                 </ItemTemplate>
  25.             </asp:TemplateField>
  26.             <asp:TemplateField HeaderText="GenreName" SortExpression="GenreName">
  27.                <EditItemTemplate>
  28.                     <asp:DropDownList ID="GenreList" runat="server" DataSourceID="GenreSqlDataSource" DataTextField="GenreName"
  29.                         DataValueField="GenreID" SelectedValue='<%# Bind("AlbumGenreID") %>'>
  30.                     </asp:DropDownList><asp:SqlDataSource ID="GenreSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
  31.                         SelectCommand="SELECT * FROM [Genre] ORDER BY [GenreName]"></asp:SqlDataSource>
  32.                 </EditItemTemplate>                <ItemTemplate>
  33.                     <asp:Label ID="GenreLabel" runat="server" Text='<%# Bind("GenreName") %>'></asp:Label>
  34.                 </ItemTemplate>
  35.             </asp:TemplateField>
  36.             <asp:TemplateField HeaderText="BandName" SortExpression="BandName">
  37.                 <EditItemTemplate>
  38.                     <asp:DropDownList ID="BandNameList" runat="server" DataSourceID="BandSqlDataSource" DataTextField="BandName"
  39.                         DataValueField="BandID" SelectedValue='<%# Bind("AlbumBandID") %>'>
  40.                     </asp:DropDownList><asp:SqlDataSource ID="BandSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
  41.                         SelectCommand="SELECT * FROM [Band] ORDER BY [BandName]"></asp:SqlDataSource>
  42.                 </EditItemTemplate>
  43.                 <ItemTemplate>
  44.                     <asp:Label ID="BandNameLabel" runat="server" Text='<%# Bind("BandName") %>'></asp:Label>
  45.                 </ItemTemplate>
  46.             </asp:TemplateField>
  47.         </Columns>
  48.         <RowStyle BackColor="Beige" BorderColor="Ivory" BorderStyle="Solid" ForeColor="DarkGreen" />
  49.         <PagerStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" ForeColor="Ivory" />
  50.         <HeaderStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" BorderWidth="1px"
  51.             ForeColor="Ivory" />
  52.         <AlternatingRowStyle BackColor="Transparent" BorderColor="Ivory" ForeColor="DarkGreen" />
  53.     </asp:GridView>
  54.     <br />
  55.     <asp:HyperLink ID="LoginLink" runat="server" NavigateUrl="~/Admin/Default.aspx">Log In</asp:HyperLink><br />
  56.     <br />
  57.     <asp:SqlDataSource ID="FullEditSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
  58.         DeleteCommand="DELETE FROM [Album] WHERE [AlbumID] = @AlbumID"
  59.         InsertCommand="INSERT INTO [Album] ([AlbumTitle], [AlbumYear], [AlbumGenreID], [AlbumBandID]) VALUES (@AlbumTitle, @AlbumYear, @AlbumGenreID, @AlbumBandID)"
  60.         SelectCommand="SELECT Album.*, Genre.GenreName, Band.BandName FROM Album INNER JOIN Band ON Album.AlbumBandID = Band.BandID INNER JOIN Genre ON Album.AlbumGenreID = Genre.GenreID"
  61.         UpdateCommand="UPDATE Album SET AlbumTitle = @AlbumTitle, AlbumYear = @AlbumYear, AlbumGenreID = @AlbumGenreID, AlbumBandID = @AlbumBandID WHERE (AlbumID = @AlbumID)">
  62.         <DeleteParameters>
  63.             <asp:Parameter Name="AlbumID" />
  64.         </DeleteParameters>
  65.         <UpdateParameters>
  66.             <asp:Parameter Name="AlbumTitle" />
  67.             <asp:Parameter Name="AlbumYear" />
  68.             <asp:Parameter Name="AlbumGenreID" />
  69.             <asp:Parameter Name="AlbumBandID" />
  70.             <asp:Parameter Name="AlbumID" />
  71.         </UpdateParameters>
  72.         <InsertParameters>
  73.             <asp:Parameter Name="AlbumTitle" />
  74.             <asp:Parameter Name="AlbumYear" />
  75.             <asp:Parameter Name="AlbumGenreID" />
  76.             <asp:Parameter Name="AlbumBandID" />
  77.         </InsertParameters>
  78.     </asp:SqlDataSource>
  79.     <asp:SqlDataSource ID="GenreSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
  80.         SelectCommand="SELECT [GenreName], [GenreID] FROM [Genre]ORDER BY [GenreName]"></asp:SqlDataSource>
  81.     <asp:SqlDataSource ID="BandSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
  82.         SelectCommand="SELECT [BandID], [BandName] FROM [Band] ORDER BY [BandName]"></asp:SqlDataSource>
  83.  
  84.     &nbsp;<br />  
  85.  
Oct 9 '07 #1
0 1525

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
3
by: adam222 | last post by:
hello, i have a web-form with a GridView control, i wanted to update & delete, using the AutoGenerateEditButton. when i used it with sqlDataSource (executing SP in the DB) it works like a...
5
by: Brian McClellan | last post by:
Just wondering if anyone has a simple example of creating a gridview completely programmatically, i'm not doing anything terribly sophisticated. When creating the gridview declaratively evertying...
5
by: Michael | last post by:
Hi Everyone, I've been having a problem with the Gridview control. I have posted a few messages relating to the issues, but I have a general question. Does the Dataview control have to be bound to...
1
by: pblack9455 | last post by:
Is it possible to do the following:- Create an ObjectDataSource object that has an embedded ArrayList of Objects. Allow the ASP.NET application to create and populate an instance of the...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
4
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
2
by: =?Utf-8?B?VGltIFRhZmZsaW5nZXI=?= | last post by:
I've created a DAL and can use the methods to load and manipulate data in a gridview when it is bound to an objectdatasource. But I've been told with a DAL I don't need an objectdatasource at all...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.