Note that there are some explanatory texts on larger screens.

plurals
  1. POSeeking Advice: Updating a FormView Based on DropdownList Value
    primarykey
    data
    text
    <p>Greetings!</p> <p>I'm looking for some advice regarding an approach to displaying data in a FormView based on a selection of a DropDownList within that FormView control. For example, I have a UserControl with the following:</p> <pre><code>&lt;asp:XmlDataSource ID="xdsMyXmlData" runat="server" EnableCaching="false" XPath="Root/Membership" /&gt; &lt;asp:FormView ID="fvwMyFormView" runat="server" DataSourceID="xdsMyXmlData"&gt; &lt;ItemTemplate&gt; &lt;div&gt; &lt;h2&gt;&lt;%# XPath("Title") %&gt;&lt;/h2&gt; &lt;fieldset&gt; &lt;asp:DropDownList ID="ddlMemberTypes" runat="server" DataSource='&lt;%# XPathSelect("MenuItems/*") %&gt;'&gt;&lt;/asp:DropDownList&gt; &lt;/fieldset&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;%# XPath("Columns/Name") %&gt;&lt;/th&gt; &lt;th&gt;&lt;%# XPath("Columns/Age") %&gt;&lt;/th&gt; &lt;th&gt;&lt;%# XPath("Columns/DateJoined")%&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;asp:Repeater ID="rptMembershipInfo" runat="server" DataSource='&lt;%# XPathSelect("Members/*") %&gt;'&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;th&gt;&lt;%# XPath("Data/Name") %&gt;&lt;/th&gt; &lt;td&gt;&lt;%# XPath("Data/Age") %&gt;&lt;/td&gt; &lt;td&gt;&lt;%# XPath("Data/DateJoined") %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/ItemTemplate&gt; &lt;/asp:FormView&gt; </code></pre> <p>The UserControl's OnLoad() looks like this so far:</p> <pre><code>protected override void OnLoad(EventArgs e) { base.OnLoad(e); string l_XmlData = MyControllerClass.GetMembershipTableXml(0); xdsMyXmlData.Data = l_XmlData; } </code></pre> <p>I would like to be able to pass the value of the DropDownList's selected item into GetMembershipTableXml() in order to retrieve the corresponding XML and then use it to populate the values of the FormView. What would the best way be to do this? Doing a Response.Redirect back to the current page using the selected DropDownList value as a query string variable? I'm hoping there's a better approach. What do you think?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload