单击按钮时的模态对话框中的DataBind GridView

时间:2017-04-24 11:22:04

标签: asp.net gridview webforms

我在模态对话框中绑定数据时遇到问题。 我有一个类似的ascx文件

<asp:Panel ID="ModalDialog" runat="server" Style="display: none;">
<asp:UpdatePanel runat="server" ID="UpdatePanel" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <ContentTemplate>
 <asp:GridView runat="server" ID="ResultGridTest" AutoGenerateColumns="true" ShowHeader="true" Width="100%" />
    </ContentTemplate>
    <Triggers>
    <asp:PostBackTrigger ControlID="ResultGridTest" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>

模态对话框作为jquery对话框打开

$j("#ModalDialog").dialog("open");

问题是,当我尝试将数据绑定到处理方法中的ResultGridTest时,该方法触发来自另一个控件的传递值,ResultGridHas没有任何可见数据。 我的处理方法:

protected void GridViewControl_DataBindGridView(object sender, PassSelectedValuesEventArgs<Model> e)
{
    ResultGridTest.DataSource = e.SelectedItems;
    ResultGridTest.DataBind();
}

你知道如何在我的模态对话框中发生事件后绑定数据吗? 请帮忙

1 个答案:

答案 0 :(得分:0)

您的UpdatePanel有一个 UpdateMode 作为条件。你需要手动更新它。添加UpdatePanel.Update();在DataBind()之后的方法。

相关问题