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