Gridview buttonclick even to update row with value

D

doomsday123

I have a gridview that displays a ORDER_ID in the first column and
then I add 2 button columns on the end of it to approve or deny the
order. If they approve it I want to update the database row's column
"status" with a 2 and if they deny the order then it will update that
column to 6. Im having trouble doing that with a AccessDataSource
control. Could someone help me figure it out. Here is what i have.


<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="ORDER_ID"
DataSourceID="ManagerQueue"
OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:HyperLinkField DataTextField="ORDER_ID"
HeaderText="ORDER_ID" SortExpression="ORDER_ID"
DataNavigateUrlFields="ORDER_ID"
DataNavigateUrlFormatString="OrderDisplay.aspx?id={0}" />
<asp:ButtonField ButtonType="Button"
CommandName="UpdateApprove" Text="Approve Order" />
<asp:ButtonField ButtonType="Button"
CommandName="UpdateReject" Text="Reject Order" />
</Columns>
</asp:GridView>
</center>
<asp:AccessDataSource ID="ManagerQueue" runat="server" DataFile="~/
App_Data/ASPNetDB.mdb"
SelectCommand="SELECT Order.ORDER_ID, Order.STATUS_ID FROM
[Order] WHERE Order.STATUS_ID=1;">
</asp:AccessDataSource>
<asp:AccessDataSource ID="ManagerQueueUpdateApprove"
runat="server" DataFile="~/App_Data/ASPNetDB.mdb"
UpdateCommand="UPDATE [Order] SET STATUS_ID = 2 WHERE ORDER_ID
= @ORDER_ID;">
</asp:AccessDataSource>
<asp:AccessDataSource ID="ManagerQueueUpdateReject" runat="server"
DataFile="~/App_Data/ASPNetDB.mdb"
UpdateCommand="UPDATE [Order] SET STATUS_ID = 6 WHERE ORDER_ID
= @ORDER_ID">
</asp:AccessDataSource>



protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "UpdateApprove")
{
ManagerQueueUpdateApprove.Update();
}
else if (e.CommandName == "UpdateReject")
{
ManagerQueueUpdateReject.Update();
}
}




it tells me "No value given for one or more required parameters." when
it tries to do the update command with either one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top