我有一个页面,在页面加载时动态获取帐号并显示在按钮中。现在点击特定帐号,我希望在没有页面加载的情况下,在按钮下方显示该帐号的完整交易。
我的aspx代码是
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%if(AccountNumbers.Count() > 0) { %>
<div class="account-message">
<p>You have following account(s). Please click to get complete transaction details :</p>
</div>
<div class="account-number-container">
<ul class="nav nav-pills" role="tablist">
<%
int count = AccountNumbers.Count();
for (int i = 0; i < count; ++i) {
%>
<li><button class="btn btn-primary" id="<%= AccountNumbers[i] %>" type="button"><%= AccountNumbers[i] %></button></li>
<%
}
%>
<li><button class="btn btn-primary" id="<%= Session["user_id"] %>" type="button">All</button></li>
</ul>
</div>
<%} else { %>
<div class="account-message">
<p>Sorry, you have no accounts</p>
</div>
<% } %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="RepeaterGetTransactions" runat="server" DataSourceID="ObjectDataSourceGetTransactions">
<HeaderTemplate>
<table id="showTransactions" class="cell-border hover">
<thead>
<tr>
<th>Transaction Id</th>
<th>Loan Amount</th>
<th>Installment</th>
<th>Transaction Date</th>
<th>Balance</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "TransactionId")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "LoanAmount")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Amount")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "TransactionDate")%>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Balance")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="ObjectDataSourceGetTransactions" runat="server"
SelectMethod="GetTransaction"
TypeName="AutoIdentificationProcess.Presenters.TransactionPresenter"></asp:ObjectDataSource>
</asp:Content>
更新面板应显示最近点击的按钮的交易。现在如何使用更新面板执行此操作。
这是我背后的代码:
//Gets the number of accounts
public List<string> GetNumberOfAccounts(string userId)
{
TransactionBAL TransactionBal = new TransactionBAL();
return TransactionBal.GetNumberOfAccounts(userId);
}
//This method gets the complete transaction details for a particular account public TransactionsBO[] GetTransaction(string accountNumber) { TransactionBAL TransactionBal = new TransactionBAL(); return TransactionBal.GetTransaction(accountNumber); }