2012-05-31 62 views
0

我有2个图像按钮,接受和拒绝。 接受按钮更新[状态] 1 拒绝按钮更新[状态] 2更新与图像按钮的Gridview

我已经成功地使用更新命令来更新接受按钮

UpdateCommand="UPDATE [bookingschedule] SET status='1'WHERE [bookingScheduleID] = @bookingScheduleID" 

但是,我不知道如何设置更新因为我只能声明一次UpdateCommand,因此可以使用Reject按钮。

UpdateCommand2="UPDATE [bookingschedule] SET status='2'WHERE [bookingScheduleID] = @bookingScheduleID" (incorrect) 

我该如何做拒绝按钮功能?我应该在哪里把这个月2日更新的命令行:

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> 

回答

0

使用控制动态存储/转发根据按钮的状态点击

UpdateCommand="UPDATE [bookingschedule] SET [email protected] WHERE [bookingScheduleID] = @bookingScheduleID" 

再加入

<asp:ControlParameter Name="Status" ControlID="StatusSelectionControl" PropertyName="Text" Type="Int32" /> 

的propertyName的应相使用的控件 - 我假设TextBox,但您也可以使用隐藏字段