0

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); 
}
Community
  • 1
  • 1
Uneverno
  • 49
  • 3
  • 14

1 Answers1

0

What you can do is just set a dummy control ID as TargetControlID for the ModalPopUpExtender and make that dummy one invisible.

Now on RowCommand event of that GridView write:

ModalPopupExtender1.Show();

Hope this will solve your problem.

Tapas Mahata
  • 343
  • 6
  • 22