问候!

我在寻找关于基于选择该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的值。将最好的办法是怎么做到这一点?做的Response.Redirect回到当前页面使用选定的DropDownList值作为查询字符串变量?我希望有一个更好的办法。你觉得呢?

有帮助吗?

解决方案

您可以创建OnSelectedItemChanged对你的DropDownList的事件;发生这种情况时,你可以抓住所选择的项目,并打电话给你GetMembershipTableXml功能。

最后,不要忘记调用DataBind您FormView控件更新值:)

我的认为的这就是你以后,希望这有助于!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top