2012-05-31 56 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,但您也可以使用隱藏字段