我有一个gridview,它在templatefield中有linkButtons:
<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为“taskLinkButton”的控件。
如果我在页面上抛出一个链接按钮并将targetControlId更改为它,弹出窗口工作正常。如何才能使用gridview中的链接按钮?
答案 0 :(得分:2)
MPE和目标控件必须位于同一个命名容器中。
将你的mpe移到gridview中,你可以在那里打开mpe的链接按钮。
此致 乌罗什
答案 1 :(得分:1)
您可以通过将targetid设置为隐藏的网格外部的链接按钮(visible = false)来将其添加到每一行。然后在click事件上调用MPE.Show()