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: -
<asp:GridView ID="FullEditAlbumGridView" runat="server" AllowPaging="True" AllowSorting="True"
-
AutoGenerateColumns="False" DataSourceID="FullEditSqlDataSource" Width="717px" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True">
-
<FooterStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" ForeColor="Ivory" />
-
<Columns>
-
<asp:BoundField DataField="AlbumID" HeaderText="AlbumID" InsertVisible="False" ReadOnly="True"
-
ShowHeader="False" SortExpression="AlbumID" Visible="False" />
-
<asp:TemplateField HeaderText="AlbumTitle" SortExpression="AlbumTitle">
-
<EditItemTemplate>
-
<asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("AlbumTitle") %>'></asp:TextBox>
-
<asp:RequiredFieldValidator ID="AlbumTitleValidator" runat="server" ErrorMessage="<br />Title is required" ControlToValidate="TitleTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
-
</EditItemTemplate>
-
<ItemTemplate>
-
<asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("AlbumTitle") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="AlbumYear" SortExpression="AlbumYear">
-
<EditItemTemplate>
-
<asp:TextBox ID="YearPubTextBox" Type="Integer" runat="server" Text='<%# Bind("AlbumYear") %>'></asp:TextBox>
-
<asp:RequiredFieldValidator ID="YearValidator" runat="server" ControlToValidate="YearPubTextBox" Display="Dynamic" ErrorMessage="<br />Year is a required field"></asp:RequiredFieldValidator>
-
-
</EditItemTemplate>
-
<ItemTemplate>
-
<asp:Label ID="YearPubLabel" runat="server" Text='<%# Bind("AlbumYear") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="GenreName" SortExpression="GenreName">
-
<EditItemTemplate>
-
<asp:DropDownList ID="GenreList" runat="server" DataSourceID="GenreSqlDataSource" DataTextField="GenreName"
-
DataValueField="GenreID" SelectedValue='<%# Bind("AlbumGenreID") %>'>
-
</asp:DropDownList><asp:SqlDataSource ID="GenreSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
-
SelectCommand="SELECT * FROM [Genre] ORDER BY [GenreName]"></asp:SqlDataSource>
-
</EditItemTemplate> <ItemTemplate>
-
<asp:Label ID="GenreLabel" runat="server" Text='<%# Bind("GenreName") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="BandName" SortExpression="BandName">
-
<EditItemTemplate>
-
<asp:DropDownList ID="BandNameList" runat="server" DataSourceID="BandSqlDataSource" DataTextField="BandName"
-
DataValueField="BandID" SelectedValue='<%# Bind("AlbumBandID") %>'>
-
</asp:DropDownList><asp:SqlDataSource ID="BandSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
-
SelectCommand="SELECT * FROM [Band] ORDER BY [BandName]"></asp:SqlDataSource>
-
</EditItemTemplate>
-
<ItemTemplate>
-
<asp:Label ID="BandNameLabel" runat="server" Text='<%# Bind("BandName") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
</Columns>
-
<RowStyle BackColor="Beige" BorderColor="Ivory" BorderStyle="Solid" ForeColor="DarkGreen" />
-
<PagerStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" ForeColor="Ivory" />
-
<HeaderStyle BackColor="DarkGreen" BorderColor="Ivory" BorderStyle="Solid" BorderWidth="1px"
-
ForeColor="Ivory" />
-
<AlternatingRowStyle BackColor="Transparent" BorderColor="Ivory" ForeColor="DarkGreen" />
-
</asp:GridView>
-
<br />
-
<asp:HyperLink ID="LoginLink" runat="server" NavigateUrl="~/Admin/Default.aspx">Log In</asp:HyperLink><br />
-
<br />
-
<asp:SqlDataSource ID="FullEditSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
-
DeleteCommand="DELETE FROM [Album] WHERE [AlbumID] = @AlbumID"
-
InsertCommand="INSERT INTO [Album] ([AlbumTitle], [AlbumYear], [AlbumGenreID], [AlbumBandID]) VALUES (@AlbumTitle, @AlbumYear, @AlbumGenreID, @AlbumBandID)"
-
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"
-
UpdateCommand="UPDATE Album SET AlbumTitle = @AlbumTitle, AlbumYear = @AlbumYear, AlbumGenreID = @AlbumGenreID, AlbumBandID = @AlbumBandID WHERE (AlbumID = @AlbumID)">
-
<DeleteParameters>
-
<asp:Parameter Name="AlbumID" />
-
</DeleteParameters>
-
<UpdateParameters>
-
<asp:Parameter Name="AlbumTitle" />
-
<asp:Parameter Name="AlbumYear" />
-
<asp:Parameter Name="AlbumGenreID" />
-
<asp:Parameter Name="AlbumBandID" />
-
<asp:Parameter Name="AlbumID" />
-
</UpdateParameters>
-
<InsertParameters>
-
<asp:Parameter Name="AlbumTitle" />
-
<asp:Parameter Name="AlbumYear" />
-
<asp:Parameter Name="AlbumGenreID" />
-
<asp:Parameter Name="AlbumBandID" />
-
</InsertParameters>
-
</asp:SqlDataSource>
-
<asp:SqlDataSource ID="GenreSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
-
SelectCommand="SELECT [GenreName], [GenreID] FROM [Genre]ORDER BY [GenreName]"></asp:SqlDataSource>
-
<asp:SqlDataSource ID="BandSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyCdsConnectionString %>"
-
SelectCommand="SELECT [BandID], [BandName] FROM [Band] ORDER BY [BandName]"></asp:SqlDataSource>
-
-
<br />
-
0 1556 Sign in to post your reply or Sign up for a free account.
Similar topics |
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
correctly but it is not updating or deleting the rows. What I did was, in
design view, added a gridview control and added an sqldatasource control. I
configured the data source to update and delete. In the gridview tasks I
selected enable...
|
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 charm, but when i want to pass the data through the
application's layers (BL etc.), it did not work.
it seems that the 'AutoGenerateEditButton' is capable only with
sqlDataSource...
|
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 works fine, however
programmatically, while the grid will display data that exsists in the
database, any operation on the data ( editing/updating/deleting ) seems to
cause a rowdeleting/updating etc error. Or is this simply not meant to be
done?
|
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 a datasource that also contains the
update/delete Sql statements? The resaon I ask is that I've done just about
all I can do and can't update the grid. In the RowUpdating event I'm getting
no values in the newvalues or oldvalues vars. I do bind a...
|
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
ObjectDataSource...and pass this to a GridView control... I don't want the
GridView control to create its own instance of the ObjectDataSource object.??
this could be where the problem is...
For example I have
| |
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 display data in a "GridView"
which is tied to an "ObjectDataSource".
In turn, this ObjectDatasource gets it's data from a strongly-typed
business object within my code.
|
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 ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the html code below.
--
Thank-you,
Barbara Alderton
<body>
|
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 what hotmail web UI is doing
now (having the option of selecting multiple rows (using the checkbox
provided) and perform a set of operations on them)
|
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 but I'm having difficulty
figuring out how to do it. Loading the data in the gridview is no problem,
it's the updating and deleting that won't work. When I click on the Edit or
Delete buttons I get an unhandled event error so apparently I need...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |