' ModalPopupExtender1'的TargetControlID无效。 ID为' lbview'无法找到

时间:2014-07-03 10:56:57

标签: asp.net ajax ajaxcontroltoolkit

<asp:GridView ID="gvstudent" AutoGenerateColumns="false" runat="server" OnRowCommand="gvstudent_RowCommand">
    <Columns>
        <asp:BoundField DataField="FName" HeaderText="Name" />
        <asp:BoundField DataField="LName" HeaderText="Surname" />
        <asp:BoundField DataField="Email" HeaderText="Email" />
        <asp:BoundField DataField="Technology" HeaderText="Technology" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="lbview" CommandName="cmdView" CommandArgument='<%#Eval("ID") %>' runat="server">View</asp:LinkButton>
                <asp:LinkButton ID="lbDelete" CommandName="cmdDelete" CommandArgument='<%#Eval("ID") %>' runat="server">Delete</asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

1 个答案:

答案 0 :(得分:2)

lbview链接按钮位于项目模板中,因此当gridview数据绑定时,其ID会发生变化,最终会像gvstudent_ctl00_lbview一样

考虑使用MPE的客户端API:$ find(“&lt;%= theModalPopupExtenderID.ClientID%&gt;”)。show()并从客户端调用它来点击lbview。并且,不要忘记取消回发。

或者,看看这里使用JS的类似场景:http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window