Is there a way to set control (in template field of gridview) as target control for modal popup extender? I tried like here:
Full postback triggered by LinkButton inside GridView inside UpdatePanel
But I get an exception as value parameter can't be null. Please help in detail.
Grid:
<asp:GridView ID="grdTemp" runat="server" AllowPaging="True" AllowSorting="True"
DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="TempNo" OnRowCommand="grdDULead_RowCommand" OnRowDataBound="grdDULead_RowDataBound">
<FooterStyle BackColor="White" CssClass="GridFooter" />
<Columns>
<asp:TemplateField><ItemTemplate><asp:LinkButton ID="grDULeadlnkSelect" runat="server" ForeColor="Red" OnClick="grDULeadlnkSelect_Click" CausesValidation="False" CommandName="selectrow">select</asp:LinkButton></ItemTemplate>
</asp:GridView>
Extender:
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="grDULeadlnkSelect" PopupControlID="pnlCDAMTClar" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
Code-behind:
At the start I got the error could not find control "grDULeadlnkSelect"
. Then I tried to register button like so but I get the error value cannot be null
.
protected void grdTemp_RowDataBound(object sender, GridViewRowEventArgs e)
{ // getting err at below line.
LinkButton lb = e.Row.FindControl("grDULeadlnkSelect") as LinkButton;
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);
}