469,962 Members | 2,341 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,962 developers. It's quick & easy.

Gridview buttonclick even to update row with value

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.

Apr 12 '07 #1
0 3953

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by | last post: by
1 post views Thread by jmdolinger | last post: by
reply views Thread by aekta | last post: by
3 posts views Thread by pvong | last post: by
14 posts views Thread by Mike | last post: by
11 posts views Thread by Ed Dror | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.