我有3個ASPLink按鈕:已解決,未解決的,取消更新場點擊
我希望能夠基於點擊該按鈕更改ResolutionStatusID領域。我不確定如何做到這一點。
即
當未解決的按鈕被點擊的值ResolutionStatusID = 3
當取消按鈕被點擊的ResolutionStatusID的值= 4
當解決按鈕被點擊的值ResolutionStatusID = 5
代碼下面
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
DeleteCommand="DELETE FROM [HardwareFault] WHERE [HardwareFaultID] = @HardwareFaultID"
InsertCommand="INSERT INTO [HardwareFault] ([FaultTitle], [ResolutionStatusID], [Message], [LoggedBy], [DateTimeLogged]) VALUES (@FaultTitle, @ResolutionStatusID, @Message, @LoggedBy, @DateTimeLogged)"
SelectCommand="SELECT dbo.ResolutionStatus.ResolutionName, dbo.HardwareFault.*, dbo.aspnet_Users.UserId, dbo.aspnet_Users.UserName FROM dbo.HardwareFault LEFT OUTER JOIN dbo.aspnet_Users ON dbo.HardwareFault.LoggedBy = dbo.aspnet_Users.UserId LEFT OUTER JOIN dbo.ResolutionStatus ON dbo.HardwareFault.ResolutionStatusID = dbo.ResolutionStatus.ResolutionStatusID WHERE [HardwareID] = @HardwareID"
UpdateCommand="UPDATE [HardwareFault] SET [ResolutionStatusID] = @ResolutionStatusID WHERE [HardwareFaultID] = @HardwareFaultID">
<DeleteParameters>
<asp:Parameter Name="HardwareFaultID" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="1" Name="HardwareID" QueryStringField="HardwareID" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="FaultTitle" Type="String" />
<asp:Parameter Name="ResolutionStatusID" Type="Int32" />
<asp:Parameter Name="Message" Type="String" />
<asp:Parameter Name="LoggedBy" Type="String" />
<asp:Parameter Name="DateTimeLogged" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ResolutionStatusID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<div>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="HardwareFaultID" DataSourceID="SqlDataSource1">
<ItemTemplate>
<tr style=""class="<%# Eval("ResolutionName") %>">
<td>
<div class="btn-group">
<a class="btn btn-mini dropdown-toggle" style="text-decoration:none; padding:3px 6px 3px 5px;" href="#" data-toggle="dropdown" title="Change Status">
<span class="icon16 icomoon-icon-cog-2" style="padding-top:7px;"></span>
<span class="caret" style="margin-top:10px;"></span>
</a>
<ul class="dropdown-menu" style="top: 33px; left: -75px; min-width: 110px; font-size: 12px;">
<li>
<asp:LinkButton ID="Resolved" OnClientClick="javascript:return confirm('Are you sure you want to change this fault to Resolved?');" runat="server" CssClass="miniDropdown">Resolved <span class="btn btn-success icon16 icomoon-icon-checkmark-2" style="text-decoration:none; padding:3px 6px 7px 5px;"></span></asp:LinkButton>
</li>
<li>
<asp:LinkButton ID="Unresolved" OnClientClick="javascript:return confirm('Are you sure you want to change this fault to Unresolved?');" runat="server" CssClass="miniDropdown">Unresolved <span class="btn btn-info icon16 typ-icon-question" style="text-decoration:none; padding:3px 6px 7px 5px;"></span></asp:LinkButton>
</li>
<li>
<asp:LinkButton ID="Cancel" OnClientClick="javascript:return confirm('Are you sure you want to Cancel this fault?');" runat="server" CssClass="miniDropdown" CommandName="Update">Cancelled <span class="btn btn-danger icon16 icomoon-icon-blocked" style="text-decoration:none; padding:3px 6px 7px 5px;"></span></asp:LinkButton>
</li>
</ul>
</div>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</div>
那麼,你有什麼問題:
C#代碼(在e.CommandName決定)?不要說「這不行」。 – 2014-10-17 02:09:27
我不知道如何做到這一點。我嘗試了很多方法來從後面的代碼更新字段,但我顯然沒有正確地做到這一點 – LeeO123 2014-10-17 03:42:01