Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 单击按钮时在模式对话框中数据绑定GridView_Asp.net_Gridview_Webforms - Fatal编程技术网

Asp.net 单击按钮时在模式对话框中数据绑定GridView

Asp.net 单击按钮时在模式对话框中数据绑定GridView,asp.net,gridview,webforms,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:

我在模态对话框中绑定数据时遇到问题。 我有一个类似的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>
问题是,当我试图将数据绑定到处理方法中的ResultGridTest时,ResultGridHas没有任何可见的数据,该处理方法根据另一个控件传递的值触发。 我的处理方法:

protected void GridViewControl_DataBindGridView(object sender, PassSelectedValuesEventArgs<Model> e)
{
    ResultGridTest.DataSource = e.SelectedItems;
    ResultGridTest.DataBind();
}
受保护的void gridview控件\u DataBindGridView(对象发送方,PassSelectedValuesEventArgs e)
{
ResultGridTest.DataSource=e.SelectedItems;
ResultGridTest.DataBind();
}
您知道如何在我的模态对话框中的事件发生后绑定数据吗?
请帮助

您的UpdatePanel有一个作为条件的UpdateMode。您需要手动将其取出。添加UpdatePanel.Update();在DataBind()之后对您的方法进行更新。

仍然不起作用,ChildrenAsTriggers应该会产生与UpdatePanelChildrenAsTriggers对立即子元素手动触发的更新方法相同的效果。根据您的说法,哪个是UpdatePanel的直接子元素?我在考虑是否在本?ResultGridTest中考虑ContentTemplate时感到困惑,它是一个子控件,在triggerpostback中定义。如果我错了,不要怪我,我是asp net web表单中的noob。请尝试使用UpdateMode=“Always”的触发器好吗?或者不使用触发器手动更新UpdatePanel?
protected void GridViewControl_DataBindGridView(object sender, PassSelectedValuesEventArgs<Model> e)
{
    ResultGridTest.DataSource = e.SelectedItems;
    ResultGridTest.DataBind();
}