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.
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.