Reputation: 137
I made a gridview which shows
OneAlbumID, Price, Condition, AlbumName.
by using configure data source
which is View, I made on Microsoft SQL
SELECT dbo.OneAlbum.OneAlbumID, dbo.Albums.AlbumName, dbo.Conditions.Condition, dbo.OneAlbum.Price
FROM dbo.OneAlbum INNER JOIN
dbo.Conditions ON dbo.OneAlbum.ConditionID = dbo.Conditions.ConditionID INNER JOIN
dbo.Albums ON dbo.OneAlbum.AlbumID = dbo.Albums.AlbumID
by joing these tables
OneAlbum-------------------------------------------------------------
OneAlbumID Primary key,
Price,
ConditionID Foreign key,
AlbumID Foreign Key
Albums---------------------------------------------------------------------
AlbumID Primary Key,
AlbumName
Condition----------------------------------------------------------------------
ConditionID Primary Key,
Condition
I try to delete a row on this gridview
I made a code on configure data source like this, which is not working
DELETE FROM [View_OneAlbums] WHERE (OneAlbumID = GridView1.SelectedValue)
the error says
The multi-part identifier "GridView1.SelectedValue" could not be bound. View or function 'View_OneAlbums' is not updatable because the modification affects multiple base tables.
how can I make/design codes to delete a row form this gridview by using Configure Data Source?
Upvotes: 0
Views: 75
Reputation: 84
First things first, you can't delete records from a DB View, as they are simply a way to visualize data, not meant for editing it.
Second, you need to know exactly what you want to delete and where that data is located within the tables referred in your view.
If you only want to remove that specific row from the GridView
(if you phrased your question correctly), Grids have built-in functions to remove certain items from the dataset that was loaded on them. Know that this will only remove from the Grid, not the DB View itself
Upvotes: 1