0

我有一个在模板字段中有链接按钮的gridview:

在此处输入图像描述

    <asp:GridView CssClass="hoursGrid" ID="hoursReportGridView" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84"
        BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource2" OnRowDataBound="hoursReportGridView_OnRowDataBound">
        <Columns>
            <asp:BoundField DataField="Person" HeaderText="Person" SortExpression="Project" />
            <asp:BoundField DataField="Project" HeaderText="Project" SortExpression="Project" />
            <asp:BoundField DataField="ProjectType" HeaderText="Project Type" ReadOnly="True" SortExpression="Sprint" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="StoryNumber" HeaderText="Story Number" SortExpression="Story" ItemStyle-Width="6%" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="StoryTitle" HeaderText="Story Title" SortExpression="Story" ItemStyle-Width="20%" />
            <asp:BoundField DataField="Task" HeaderText="Task" SortExpression="Task"  ItemStyle-Width="20%" />
            <asp:BoundField DataField="Monday" HeaderText="Monday" ReadOnly="True" SortExpression="Monday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Tuesday" HeaderText="Tuesday" ReadOnly="True" SortExpression="Tuesday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Wednesday" HeaderText="Wednesday" ReadOnly="True" SortExpression="Wednesday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Thursday" HeaderText="Thursday" ReadOnly="True" SortExpression="Thursday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Friday" HeaderText="Friday" ReadOnly="True" SortExpression="Friday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Saturday" HeaderText="Saturday" ReadOnly="True" SortExpression="Saturday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Sunday" HeaderText="Sunday" ReadOnly="True" SortExpression="Sunday" ItemStyle-HorizontalAlign="Right" />
            <asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right">
                <ItemTemplate>
                     <asp:LinkButton ID="taskLinkButton" Text='<%# Eval("Total") %>' Visible='<%# Eval("StoryTitle").ToString() != "" %>' runat="server" OnClick="taskLinkButton_Click" />
                     <asp:Literal ID="Literal1" Text='<%# Eval("Total") %>' Visible='<%# Eval("StoryTitle") == "" %>' runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

当我单击一个链接时,我希望出现一个弹出窗口:

<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
    TargetControlID="taskLinkButton"
    PopupControlID="infoPanel"
    DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="infoPanel" runat="server">CONTENT HERE</asp:Panel>

但是我收到以下错误:

“MPE”的 TargetControlID 无效。找不到 ID 为“taskLinkBut​​ton”的控件。

如果我在页面上抛出一个链接按钮并将 targetControlId 更改为它,则弹出窗口工作正常。如何让它与我的 gridview 中的链接按钮一起使用?

4

2 回答 2

2

MPE 和目标控件必须在同一个命名容器中。

将您的 mpe 移动到 gridview 中,您可以在其中打开 mpe 的链接按钮。

问候,乌罗斯

于 2013-10-30T20:33:43.407 回答
1

您可以通过将 targetid 设置为您隐藏的网格外部的链接按钮来绕过将其添加到每一行,可见 = false。然后在点击事件上只需调用 MPE.Show()

于 2013-10-30T20:43:06.567 回答