0
問候!尋求建議:基於DropdownList值更新FormView
我正在尋找一些關於在FormView控件中基於DropDownList的選擇在FormView中顯示數據的方法的建議。例如,我有以下內容的用戶控件:
<asp:XmlDataSource ID="xdsMyXmlData" runat="server" EnableCaching="false" XPath="Root/Membership" />
<asp:FormView ID="fvwMyFormView" runat="server" DataSourceID="xdsMyXmlData">
<ItemTemplate>
<div>
<h2><%# XPath("Title") %></h2>
<fieldset>
<asp:DropDownList ID="ddlMemberTypes" runat="server" DataSource='<%# XPathSelect("MenuItems/*") %>'></asp:DropDownList>
</fieldset>
<table>
<thead>
<tr>
<th><%# XPath("Columns/Name") %></th>
<th><%# XPath("Columns/Age") %></th>
<th><%# XPath("Columns/DateJoined")%></th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptMembershipInfo" runat="server" DataSource='<%# XPathSelect("Members/*") %>'>
<ItemTemplate>
<tr>
<th><%# XPath("Data/Name") %></th>
<td><%# XPath("Data/Age") %></td>
<td><%# XPath("Data/DateJoined") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
</ItemTemplate>
</asp:FormView>
的用戶控件的OnLoad()看起來像這樣至今:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string l_XmlData = MyControllerClass.GetMembershipTableXml(0);
xdsMyXmlData.Data = l_XmlData;
}
我希望能夠通過的DropDownList的選擇值項轉換爲GetMembershipTableXml()以檢索相應的XML,然後使用它填充FormView的值。最好的辦法是做什麼?使用選定的DropDownList值作爲查詢字符串變量,將Response.Redirect返回到當前頁面?我希望有更好的方法。你怎麼看?
我想我需要將我的代碼當前放在我的OnLoad中的「if(!IsPostBack)」塊中? – Bullines 2009-01-28 01:21:07