How do I get this update command to work in gridview?
I have a gridview that properly pulls the data as I need it. I have it set to custom queries since I am using stored procedures to update and delete the info. I am running a delete command and an update command, but only the delete command works.
My update command seems to be set up correctly, but when I change the name of one of the items and click update, the grid goes back to where it was before without the change. I also do not get an error message, so I'm not sure how to troubleshoot this. I've scoured the net trying to find an answer, but none seem to work for this situation. Is it possible the "original" parameters are causing an issue? I want the grid to take the old value as the check in the table. If this is causing the issue, is there another way to do it?
Thanks in advance!
Here is my gridview code:
<asp:GridView ID="gvArtists"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="gridView_Artists"
CssClass="table table-bordered table-condensed table-hover"
OnPreRender="gvArtists_PreRender"
OnRowDeleted="gvArtists_RowDeleted"
OnRowUpdated="gvArtists_RowUpdated">
<Columns>
<asp:BoundField DataField="artist_FirstName" HeaderText="First Name"
SortExpression="artist_FirstName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_LastName" HeaderText="Last Name"
SortExpression="artist_LastName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_band" HeaderText="Band"
SortExpression="artist_band" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_type" HeaderText="Type"
SortExpression="artist_type" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:CommandField CausesValidation="False" ShowEditButton="True">
<ItemStyle CssClass="col-xs-1 text-danger" />
</asp:CommandField>
<asp:CommandField CausesValidation="False" ShowDeleteButton="True">
<ItemStyle CssClass="col-xs-1" />
</asp:CommandField>
</Columns>
<HeaderStyle CssClass="bg-halloween" />
<AlternatingRowStyle CssClass="altRow" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle CssClass="pagerStyle" BackColor="#a8c8c8c" HorizontalAlign="Center" />
<EditRowStyle CssClass="warning" />
</asp:GridView>
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
Here is my stored procedures for update:
create proc sp_UpdateArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50),
@original_artist_FirstName varchar(50),
@original_artist_LastName varchar(50),
@original_artist_band varchar(50),
@original_artist_type varchar(50)
)
as
begin
--start error checking
begin try
update ArtistInfo
set
artist_FirstName = @artist_FirstName,
artist_LastName = @artist_LastName,
artist_band = @artist_band,
artist_type = @artist_type
WHERE artist_FirstName = @original_artist_FirstName
AND artist_LastName = @original_artist_LastName
AND artist_band = @original_artist_band
AND artist_type = @original_artist_type
--display the change
end try
begin catch
print error_message()
end catch
end
go
and for delete:
create proc sp_DeleteArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50)
)
as
begin
--start error checking
begin try
DELETE FROM DiskHasArtist
FROM DiskHasArtist INNER JOIN
ArtistInfo ON DiskHasArtist.artist_ID = ArtistInfo.artist_ID
WHERE ArtistInfo.artist_FirstName = @artist_FirstName
AND ArtistInfo.artist_LastName = @artist_LastName
AND ArtistInfo.artist_band = @artist_band
AND ArtistInfo.artist_type = @artist_type
delete from ArtistInfo
WHERE artist_FirstName = @artist_FirstName
AND artist_LastName = @artist_LastName
AND artist_band = @artist_band
AND artist_type = @artist_type
end try
begin catch
print error_message()
end catch
end
go
c# asp.net gridview visual-studio-2017
add a comment |
I have a gridview that properly pulls the data as I need it. I have it set to custom queries since I am using stored procedures to update and delete the info. I am running a delete command and an update command, but only the delete command works.
My update command seems to be set up correctly, but when I change the name of one of the items and click update, the grid goes back to where it was before without the change. I also do not get an error message, so I'm not sure how to troubleshoot this. I've scoured the net trying to find an answer, but none seem to work for this situation. Is it possible the "original" parameters are causing an issue? I want the grid to take the old value as the check in the table. If this is causing the issue, is there another way to do it?
Thanks in advance!
Here is my gridview code:
<asp:GridView ID="gvArtists"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="gridView_Artists"
CssClass="table table-bordered table-condensed table-hover"
OnPreRender="gvArtists_PreRender"
OnRowDeleted="gvArtists_RowDeleted"
OnRowUpdated="gvArtists_RowUpdated">
<Columns>
<asp:BoundField DataField="artist_FirstName" HeaderText="First Name"
SortExpression="artist_FirstName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_LastName" HeaderText="Last Name"
SortExpression="artist_LastName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_band" HeaderText="Band"
SortExpression="artist_band" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_type" HeaderText="Type"
SortExpression="artist_type" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:CommandField CausesValidation="False" ShowEditButton="True">
<ItemStyle CssClass="col-xs-1 text-danger" />
</asp:CommandField>
<asp:CommandField CausesValidation="False" ShowDeleteButton="True">
<ItemStyle CssClass="col-xs-1" />
</asp:CommandField>
</Columns>
<HeaderStyle CssClass="bg-halloween" />
<AlternatingRowStyle CssClass="altRow" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle CssClass="pagerStyle" BackColor="#a8c8c8c" HorizontalAlign="Center" />
<EditRowStyle CssClass="warning" />
</asp:GridView>
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
Here is my stored procedures for update:
create proc sp_UpdateArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50),
@original_artist_FirstName varchar(50),
@original_artist_LastName varchar(50),
@original_artist_band varchar(50),
@original_artist_type varchar(50)
)
as
begin
--start error checking
begin try
update ArtistInfo
set
artist_FirstName = @artist_FirstName,
artist_LastName = @artist_LastName,
artist_band = @artist_band,
artist_type = @artist_type
WHERE artist_FirstName = @original_artist_FirstName
AND artist_LastName = @original_artist_LastName
AND artist_band = @original_artist_band
AND artist_type = @original_artist_type
--display the change
end try
begin catch
print error_message()
end catch
end
go
and for delete:
create proc sp_DeleteArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50)
)
as
begin
--start error checking
begin try
DELETE FROM DiskHasArtist
FROM DiskHasArtist INNER JOIN
ArtistInfo ON DiskHasArtist.artist_ID = ArtistInfo.artist_ID
WHERE ArtistInfo.artist_FirstName = @artist_FirstName
AND ArtistInfo.artist_LastName = @artist_LastName
AND ArtistInfo.artist_band = @artist_band
AND ArtistInfo.artist_type = @artist_type
delete from ArtistInfo
WHERE artist_FirstName = @artist_FirstName
AND artist_LastName = @artist_LastName
AND artist_band = @artist_band
AND artist_type = @artist_type
end try
begin catch
print error_message()
end catch
end
go
c# asp.net gridview visual-studio-2017
add a comment |
I have a gridview that properly pulls the data as I need it. I have it set to custom queries since I am using stored procedures to update and delete the info. I am running a delete command and an update command, but only the delete command works.
My update command seems to be set up correctly, but when I change the name of one of the items and click update, the grid goes back to where it was before without the change. I also do not get an error message, so I'm not sure how to troubleshoot this. I've scoured the net trying to find an answer, but none seem to work for this situation. Is it possible the "original" parameters are causing an issue? I want the grid to take the old value as the check in the table. If this is causing the issue, is there another way to do it?
Thanks in advance!
Here is my gridview code:
<asp:GridView ID="gvArtists"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="gridView_Artists"
CssClass="table table-bordered table-condensed table-hover"
OnPreRender="gvArtists_PreRender"
OnRowDeleted="gvArtists_RowDeleted"
OnRowUpdated="gvArtists_RowUpdated">
<Columns>
<asp:BoundField DataField="artist_FirstName" HeaderText="First Name"
SortExpression="artist_FirstName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_LastName" HeaderText="Last Name"
SortExpression="artist_LastName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_band" HeaderText="Band"
SortExpression="artist_band" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_type" HeaderText="Type"
SortExpression="artist_type" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:CommandField CausesValidation="False" ShowEditButton="True">
<ItemStyle CssClass="col-xs-1 text-danger" />
</asp:CommandField>
<asp:CommandField CausesValidation="False" ShowDeleteButton="True">
<ItemStyle CssClass="col-xs-1" />
</asp:CommandField>
</Columns>
<HeaderStyle CssClass="bg-halloween" />
<AlternatingRowStyle CssClass="altRow" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle CssClass="pagerStyle" BackColor="#a8c8c8c" HorizontalAlign="Center" />
<EditRowStyle CssClass="warning" />
</asp:GridView>
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
Here is my stored procedures for update:
create proc sp_UpdateArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50),
@original_artist_FirstName varchar(50),
@original_artist_LastName varchar(50),
@original_artist_band varchar(50),
@original_artist_type varchar(50)
)
as
begin
--start error checking
begin try
update ArtistInfo
set
artist_FirstName = @artist_FirstName,
artist_LastName = @artist_LastName,
artist_band = @artist_band,
artist_type = @artist_type
WHERE artist_FirstName = @original_artist_FirstName
AND artist_LastName = @original_artist_LastName
AND artist_band = @original_artist_band
AND artist_type = @original_artist_type
--display the change
end try
begin catch
print error_message()
end catch
end
go
and for delete:
create proc sp_DeleteArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50)
)
as
begin
--start error checking
begin try
DELETE FROM DiskHasArtist
FROM DiskHasArtist INNER JOIN
ArtistInfo ON DiskHasArtist.artist_ID = ArtistInfo.artist_ID
WHERE ArtistInfo.artist_FirstName = @artist_FirstName
AND ArtistInfo.artist_LastName = @artist_LastName
AND ArtistInfo.artist_band = @artist_band
AND ArtistInfo.artist_type = @artist_type
delete from ArtistInfo
WHERE artist_FirstName = @artist_FirstName
AND artist_LastName = @artist_LastName
AND artist_band = @artist_band
AND artist_type = @artist_type
end try
begin catch
print error_message()
end catch
end
go
c# asp.net gridview visual-studio-2017
I have a gridview that properly pulls the data as I need it. I have it set to custom queries since I am using stored procedures to update and delete the info. I am running a delete command and an update command, but only the delete command works.
My update command seems to be set up correctly, but when I change the name of one of the items and click update, the grid goes back to where it was before without the change. I also do not get an error message, so I'm not sure how to troubleshoot this. I've scoured the net trying to find an answer, but none seem to work for this situation. Is it possible the "original" parameters are causing an issue? I want the grid to take the old value as the check in the table. If this is causing the issue, is there another way to do it?
Thanks in advance!
Here is my gridview code:
<asp:GridView ID="gvArtists"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="gridView_Artists"
CssClass="table table-bordered table-condensed table-hover"
OnPreRender="gvArtists_PreRender"
OnRowDeleted="gvArtists_RowDeleted"
OnRowUpdated="gvArtists_RowUpdated">
<Columns>
<asp:BoundField DataField="artist_FirstName" HeaderText="First Name"
SortExpression="artist_FirstName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_LastName" HeaderText="Last Name"
SortExpression="artist_LastName" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_band" HeaderText="Band"
SortExpression="artist_band" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="artist_type" HeaderText="Type"
SortExpression="artist_type" ItemStyle-CssClass="col-xs-3" >
<ItemStyle CssClass="col-xs-3"></ItemStyle>
</asp:BoundField>
<asp:CommandField CausesValidation="False" ShowEditButton="True">
<ItemStyle CssClass="col-xs-1 text-danger" />
</asp:CommandField>
<asp:CommandField CausesValidation="False" ShowDeleteButton="True">
<ItemStyle CssClass="col-xs-1" />
</asp:CommandField>
</Columns>
<HeaderStyle CssClass="bg-halloween" />
<AlternatingRowStyle CssClass="altRow" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle CssClass="pagerStyle" BackColor="#a8c8c8c" HorizontalAlign="Center" />
<EditRowStyle CssClass="warning" />
</asp:GridView>
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
Here is my stored procedures for update:
create proc sp_UpdateArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50),
@original_artist_FirstName varchar(50),
@original_artist_LastName varchar(50),
@original_artist_band varchar(50),
@original_artist_type varchar(50)
)
as
begin
--start error checking
begin try
update ArtistInfo
set
artist_FirstName = @artist_FirstName,
artist_LastName = @artist_LastName,
artist_band = @artist_band,
artist_type = @artist_type
WHERE artist_FirstName = @original_artist_FirstName
AND artist_LastName = @original_artist_LastName
AND artist_band = @original_artist_band
AND artist_type = @original_artist_type
--display the change
end try
begin catch
print error_message()
end catch
end
go
and for delete:
create proc sp_DeleteArtistInfo
(
@artist_FirstName varchar(50),
@artist_LastName varchar(50),
@artist_band varchar(50),
@artist_type varchar(50)
)
as
begin
--start error checking
begin try
DELETE FROM DiskHasArtist
FROM DiskHasArtist INNER JOIN
ArtistInfo ON DiskHasArtist.artist_ID = ArtistInfo.artist_ID
WHERE ArtistInfo.artist_FirstName = @artist_FirstName
AND ArtistInfo.artist_LastName = @artist_LastName
AND ArtistInfo.artist_band = @artist_band
AND ArtistInfo.artist_type = @artist_type
delete from ArtistInfo
WHERE artist_FirstName = @artist_FirstName
AND artist_LastName = @artist_LastName
AND artist_band = @artist_band
AND artist_type = @artist_type
end try
begin catch
print error_message()
end catch
end
go
c# asp.net gridview visual-studio-2017
c# asp.net gridview visual-studio-2017
asked Nov 26 '18 at 5:18
aarmfieldaarmfield
377
377
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I figured out the issue. I did not include the property "OldValuesParameterFormatString" so the app knows to pass my "original_" parameters.
Here is the new code:
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp:Parameter Name="original_artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
The OldValuesParameterFormatString="original_{0}" part tells the app to use the parameters.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475111%2fhow-do-i-get-this-update-command-to-work-in-gridview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I figured out the issue. I did not include the property "OldValuesParameterFormatString" so the app knows to pass my "original_" parameters.
Here is the new code:
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp:Parameter Name="original_artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
The OldValuesParameterFormatString="original_{0}" part tells the app to use the parameters.
add a comment |
I figured out the issue. I did not include the property "OldValuesParameterFormatString" so the app knows to pass my "original_" parameters.
Here is the new code:
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp:Parameter Name="original_artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
The OldValuesParameterFormatString="original_{0}" part tells the app to use the parameters.
add a comment |
I figured out the issue. I did not include the property "OldValuesParameterFormatString" so the app knows to pass my "original_" parameters.
Here is the new code:
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp:Parameter Name="original_artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
The OldValuesParameterFormatString="original_{0}" part tells the app to use the parameters.
I figured out the issue. I did not include the property "OldValuesParameterFormatString" so the app knows to pass my "original_" parameters.
Here is the new code:
<asp:SqlDataSource
ID="gridView_Artists"
runat="server"
ConnectionString="<%$ ConnectionStrings:disk_inventoryConnectionString %>"
SelectCommand="SELECT artist_FirstName,
artist_LastName,
artist_band,
artist_type
FROM ArtistInfo
ORDER BY artist_LastName"
DeleteCommand="sp_DeleteArtistInfo"
DeleteCommandType="StoredProcedure"
UpdateCommand="sp_UpdateArtistInfo"
UpdateCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp:Parameter Name="original_artist_FirstName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_band" Type="String"></asp:Parameter>
<asp:Parameter Name="original_artist_type" Type="String"></asp:Parameter>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="artist_FirstName"></asp:Parameter>
<asp:Parameter Name="artist_LastName"></asp:Parameter>
<asp:Parameter Name="artist_band"></asp:Parameter>
<asp:Parameter Name="artist_type"></asp:Parameter>
<asp:Parameter Name="original_artist_FirstName"></asp:Parameter>
<asp:Parameter Name="original_artist_LastName"></asp:Parameter>
<asp:Parameter Name="original_artist_band"></asp:Parameter>
<asp:Parameter Name="original_artist_type"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
The OldValuesParameterFormatString="original_{0}" part tells the app to use the parameters.
answered Nov 26 '18 at 18:41
aarmfieldaarmfield
377
377
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475111%2fhow-do-i-get-this-update-command-to-work-in-gridview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown