我有一個使用兩個列表框和第三方控件(Fluent.ListTransfer)將值從一個列表轉移到另一個列表的ASP頁面。相當標準的東西:如何在用戶控件上維護視圖狀態
<td>
<asp:ListBox ID="ListBoxAvailable" Runat="server"
SelectionMode="Multiple" EnableViewState="true">
</asp:ListBox>
</td>
<td style="vertical-align: middle">
<a href="#" onclick="<%= ListTransfer1.ClientMoveSelected %>" ><img src="img/RightArrow.jpg" alt=">>"/></a>
<br />
<a href="#" onclick="<%= ListTransfer1.ClientMoveBackSelected %>"><img src="img/LeftArrow.jpg" alt="<<"/></a>
</td>
<td>
<asp:ListBox ID="ListBoxSelected" Runat="server"
SelectionMode="Multiple" EnableViewState="true">
</asp:ListBox>
</td>
在控件Page_Load事件,我設置了「可用」和「選擇」框的一些SQL內容:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;
// Some code to work through a recordset, adding values
// to the selected or available list boxes
我認爲上回發,視圖狀態會照顧列表框的狀態,由用戶更改(畢竟,它們是標準的ASP控件)。但是,如果我做回發,這兩個列表框都是空白的。
在回發之間維護列表框狀態的正確方法是什麼?
感謝所有幫助
瑞安
非常有幫助。謝謝! – Ryan 2010-02-26 11:55:22