我有 2 个图像按钮,接受和拒绝。接受按钮将 [status] 更新为 1 拒绝按钮将 [status] 更新为 2
我已成功使用 UpdateCommand 更新接受按钮
UpdateCommand="UPDATE [bookingschedule] SET status='1'WHERE [bookingScheduleID] = @bookingScheduleID"
但是,我不知道如何为拒绝按钮设置更新命令,因为我只能声明一次 UpdateCommand。
UpdateCommand2="UPDATE [bookingschedule] SET status='2'WHERE [bookingScheduleID] = @bookingScheduleID" (incorrect)
我应该怎么做才能使拒绝按钮功能?我应该把这个第二个更新命令行放在哪里:
UpdateCommand="UPDATE [bookingschedule] SET status='2'WHERE [bookingScheduleID] = @bookingScheduleID"
我在客户端完成所有这些编码:
接受按钮:
<asp:TemplateField HeaderText="Action Approve">
<ItemTemplate>
<asp:ImageButton runat="server" ID="UpdateCommand"
CommandName="update" ImageUrl="~/images/accept.png"
OnClientClick="if (!window.confirm('Are you sure you want to approve this booking?')) return false;" />
</ItemTemplate>
</asp:TemplateField>
拒绝按钮:
<asp:TemplateField HeaderText="Action Reject">
<ItemTemplate>
<asp:ImageButton runat="server" ID="UpdateCommand" CommandName="update" OnClick="reject"
ImageUrl="~/images/reject.png"
OnClientClick="if (!window.confirm('Are you sure you want to reject this booking?')) return false;" />
</ItemTemplate>
</asp:TemplateField>
SQL 数据源:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [bookingScheduleID], [eventTitle], [week1], [week2], [week3], [week4], [week5], [week6], [week7], [week8], [exhibitorname], [boothAlias], [category], [status], [dateBook],[custNo] FROM [booking_all]"
UpdateCommand="UPDATE [bookingschedule] SET status='1'WHERE [bookingScheduleID] = @bookingScheduleID"
>
</asp:SqlDataSource>
<UpdateParameters>
<asp:Parameter Name="bookingScheduleID" Type="Int32" />
</UpdateParameters>