使用 ModalPopupExtender 显示表格,然后将选定的记录传递到表单

发布于 2024-10-10 11:27:33 字数 287 浏览 0 评论 0原文

我的网站上有一个搜索屏幕,其中有各种参数。有可能返回多条记录,但用户只想查看一条记录的详细信息。在返回许多记录的情况下,我想显示一个带有数据网格的模式弹出窗口,该窗口将显示一些核心字段,然后用户可以从那里选择他们想要更详细地查看的记录,然后它将关闭modal-window 并将它们带回到显示其他详细信息的主页。

我想知道如何将数据(将在列表集合中)从我的 aspx 页面传递到弹出窗口并使用信息填充网格。

我尝试过服务器端,但弹出窗口(即数据网格)上的控件未初始化。我一直在寻找,但在网络上找不到任何显示如何执行此操作的内容。

I have a search screen on my website which has various parameters. It is possible that many records could be returned, yet the user will only want to see the details of one record. In the case where many records are returned I want to display a modal popwindow with a data grid which will display some of the core fields and then from there the user can select the record they want to see in more detail and it will then close the modal-window and take them back to the main page where additional details are displayed.

I want to know how to pass the data (which will be in a list collection) from my aspx page to the popup window and populate the grid with the information.

I have tried server side but the controls on the popup (i.e. the datagrid) are not initialized. I have been looking but can't find anything on the web which shows how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心碎的声音 2024-10-17 11:27:34

好的,这就是您可以执行的操作:

添加网格,我通常在面板内执行此操作

<asp:Panel ID="pnStudios" runat="server">
<asp:GridView ID="gvStudios" runat="server" OnSelectedIndexChanged="gvStudios_SelectedIndexChanged">
</asp:GridView>
</asp:Panel> 

将 mpe 链接到面板

<asp:ModalPopupExtender ID="mpeStudios" runat="server" BehaviorID="mpeStudios"  Enabled="True" TargetControlID="txtStudio" PopupControlID="pnStudios">
</asp:ModalPopupExtender>

在您的情况下,您可以将 TargetControlID 留空。

当您想显示它时,请使用此

gvStudios.DataSource = studios;
gvStudios.DataBind();
mpeStudios.Show();

Where studios 是一个列表集合。

在网格的 OnSelectedIndexChanged 中,您可以获取所选值并获取详细信息,以便您可以在主页中显示它们,回发完成后 mpe 将自动关闭。

希望有帮助。

Ok, this is what you can do:

Add the grid, I usually do it inside a panel

<asp:Panel ID="pnStudios" runat="server">
<asp:GridView ID="gvStudios" runat="server" OnSelectedIndexChanged="gvStudios_SelectedIndexChanged">
</asp:GridView>
</asp:Panel> 

Link the mpe to the panel

<asp:ModalPopupExtender ID="mpeStudios" runat="server" BehaviorID="mpeStudios"  Enabled="True" TargetControlID="txtStudio" PopupControlID="pnStudios">
</asp:ModalPopupExtender>

In your case you can leave the TargetControlID empty.

When you want to show it use this

gvStudios.DataSource = studios;
gvStudios.DataBind();
mpeStudios.Show();

Where studios is a list collection.

In the OnSelectedIndexChanged of the grid you can get the selected value and get the details so you can show them in your main page, the mpe will close automatically when a postback is done.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文