views:

729

answers:

1

Hi,

I am trying to add a ModalPopup to a GridView, by adding a button in the data grid header:

<asp:GridView ID="GridViewTradeDetail" />
    <Columns>
        <asp:TemplateField HeaderText="B/S">
            <HeaderTemplate>
                <asp:Button ID="ButtonShowBuySellPopup" runat="server" Text="Set B/S" />
            </HeaderTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("buy_sell") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("buy_sell") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="trade_date" HeaderText="TD" />
    </Columns>
</asp:GridView>

...

<asp:Panel ID="PanelBuySell" runat="server">
    ... panel content ...
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderBuySell" runat="server"
    TargetControlID="ButtonShowBuySellPopup" PopupControlID="PanelBuySell" />
<asp:Button ID="ButtonShowBuySellPopup" runat="server" Text="Set B/S" />

But I get an error that the ModalPopupExtender cannot find the button ButtonShowBuySellPopup (If I move the button out of the grid header it's OK).

How can I link the popup to a button (or better still, text link) in the header of a Gridiew?

Thank you

Ryan

A: 

I found a great workaround to this here:

http://stackoverflow.com/questions/965869/asp-net-dynamic-modalpopupextender

Ryan