title: how to pop up two modalpopup in gridview
body: <p>I want to pop up two modalpopup from a gridview.  I searched online but couldn't find the exact answer.  Any help is appreciated.</p>
  
  <pre><code>--------ModalPopupExtender1---------
  
  &lt;asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
  BackgroundCssClass="ModalPopupBG" CancelControlID="btn_Cancel" Drag="true" 
  PopupControlID="Panel2" PopupDragHandleControlID="Panel2" 
  TargetControlID="btnNew"&gt;
  &lt;/asp:ModalPopupExtender&gt;
  
  -----------------PopupControlID="Panel2--------------------------
  &lt;div id="Panel2" class="popupConfirmation"&gt;
    &lt;div class="popup_Container"&gt;
      &lt;div id="PopupHeader" class="popup_Titlebar"&gt;
        &lt;div class="TitlebarLeft"&gt;
          &lt;%--
          &lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
          &lt;/asp:ToolkitScriptManager&gt;
          --%&gt;
          Edit Customer
        &lt;/div&gt;
        &lt;!--
  &lt;div class="TitlebarRight" &gt;
  &lt;/div&gt;
  --&gt;
                                        &lt;/div&gt;
                                        &lt;div&gt;
                                          &lt;table bgcolor="#CCFFFF" cellpadding="0" cellspacing="2" width="100%"&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="25%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="65%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &lt;asp:LabelID="lblName"runat="server"FontSize="11pt" Text="First Name:"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &lt;asp:TextBox ID="txtFirstName" runat="server" Width="300px"&gt;
                                                &lt;/asp:TextBox&gt;
                                                &lt;asp:Label ID="lbl_ErrorName" runat="server" ForeColor="Red" 
                                                style="display:none" Text="*"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &lt;asp:Label ID="lblName2" runat="server" Font-Size="11pt" Text="Second Name:"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &lt;asp:TextBox ID="txtSecondName" runat="server" Width="300px"&gt;
                                                &lt;/asp:TextBox&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;%-- 
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="45%"&gt;
                                                &lt;asp:Label ID="lblName0" runat="server" Font-Size="11pt" Text="City"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="45%"&gt;
                                                &lt;asp:TextBox ID="txtCity" runat="server" Width="200px"&gt;
                                                &lt;/asp:TextBox&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="45%"&gt;
                                                &lt;asp:Label ID="lblName1" runat="server" Font-Size="11pt" Text="State"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="45%"&gt;
                                                &lt;asp:TextBox ID="txtState" runat="server" Width="200px"&gt;
                                                &lt;/asp:TextBox&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            --%&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &lt;asp:Label ID="lblAddress1" runat="server" Font-Size="11pt" Text="Address1:"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &lt;asp:TextBox ID="txtAddress1" runat="server" Width="300px"&gt;
                                                &lt;/asp:TextBox&gt;
                                                &lt;asp:Label ID="lbl_ErrorAddress1" runat="server" ForeColor="Red" 
                                                style="display:none" Text="*"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;%-- 
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="45%"&gt;
                                                &lt;asp:Label ID="lblAddress2" runat="server" Font-Size="11pt" Text="Address2:"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="45%"&gt;
                                                &lt;asp:TextBox ID="txtAddress2" runat="server" Width="200px"&gt;
                                                &lt;/asp:TextBox&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            --%&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &lt;asp:Label ID="lblDOB" runat="server" Font-Size="11pt" Text="Phone"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &lt;asp:TextBox ID="txtPhone" runat="server" Width="200px"&gt;
                                                &lt;/asp:TextBox&gt;
  
  
                                                &lt;%--
                                                &lt;asp:CalendarExtender ID="txt_DOB_CalendarExtender" runat="server" 
                                                TargetControlID="txt_DOB"&gt;
                                                &lt;/asp:CalendarExtender&gt;
                                                --%&gt;
  
  
                                                &lt;asp:Label ID="lblErrorDOB" runat="server" Font-Bold="True" ForeColor="Red" 
                                                style="display:none" Text="*"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &lt;asp:Label ID="lblDOB0" runat="server" Font-Size="11pt" Text="Mobile"&gt;
                                                &lt;/asp:Label&gt;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &lt;asp:TextBox ID="txtMobile" runat="server" Width="200px"&gt;
                                                &lt;/asp:TextBox&gt;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: right" width="25%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td style="text-align: left" width="65%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                              &lt;td width="5%"&gt;
                                                &amp;nbsp;
                                              &lt;/td&gt;
                                            &lt;/tr&gt;
                                          &lt;/table&gt;
                                        &lt;/div&gt;
                                        &lt;div align="center"&gt;
                                          &amp;nbsp;
                                          &lt;asp:Button ID="btn_Update" runat="server"  
                                          Text="Save" Width="75px" onclick="btn_Update_Click" /&gt;
                                          &lt;asp:Button ID="btn_Cancel" runat="server" Text="Cancel" Width="75px" /&gt;
                                          &amp;nbsp;
                                        &lt;/div&gt;
        &lt;/div&gt;
  &lt;/div&gt;
  ----------------`ModalpopUp`----------------------------
           &lt;asp:ModalPopupExtender ID="ModalPopUp" runat="server" 
                              CancelControlID="idclose" Drag="true" DynamicServicePath="" Enabled="True" 
                              PopupControlID="PartyCustomers_idbody" 
                              PopupDragHandleControlID="PartyCustomers_IdTitle" 
                              TargetControlID="btnShowPopup"&gt;
                              &lt;Animations&gt;
              &lt;OnShown&gt;&lt;Fadein Duration="0.50" /&gt;&lt;/OnShown&gt;
              &lt;OnHiding&gt;&lt;Fadeout Duration="0.75" /&gt;&lt;/OnHiding&gt;
          &lt;/Animations&gt;
                          &lt;/asp:ModalPopupExtender&gt;
  --------------------PartyCustomers_idbody : popupbody--------------
  `&lt;div id="PartyCustomers_idbody" runat="server" class="Common_divbody" 
                              &gt;
                              &lt;div id="PartyCustomers_IdTitle" runat="server" class="Common_divtitle" 
                                  &gt;
                                  &lt;div id="idclose" class="Common_close"&gt;
                                  &lt;/div&gt;
                                  &lt;div class="Common_divhr"&gt;
                                      Booked Status&lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="ModalPopUpDiv"&gt;
                              &lt;asp:Label ID="lblmessage1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
                                  &amp;nbsp;
                                  &lt;asp:GridView ID="dgvSystemDetails" runat="server" AllowPaging="True" 
                                      AllowSorting="True" AlternatingRowStyle-CssClass="alt" 
                                      AutoGenerateColumns="False" CellSpacing="2" CssClass="mGrid" Font-Bold="True" 
                                      Font-Names="Arial" Font-Size="Small" PageSize="12"  
                                      Width="750px" DataKeyNames="SystemCode" 
                                      onrowdatabound="dgvSystemDetails_RowDataBound"&gt;
                                      &lt;AlternatingRowStyle CssClass="alt" /&gt;
                                      &lt;Columns&gt;
                                          &lt;asp:BoundField DataField="RegistrationDate" DataFormatString="{0:d}" 
                                              HeaderText="Registration Date"&gt;
                                          &lt;HeaderStyle /&gt;
                                          &lt;ItemStyle /&gt;
                                          &lt;/asp:BoundField&gt;
                                          &lt;asp:BoundField DataField="SystemCode" HeaderText="System Code" /&gt;
                                          &lt;asp:BoundField DataField="Reg_Status" HeaderText="Reg. Status" /&gt;
                                          &lt;asp:BoundField DataField="Key" HeaderText="Key" /&gt;
                                          &lt;asp:TemplateField&gt;
                                              &lt;ItemTemplate&gt;
                                                  &lt;asp:Button ID="btnBlock" runat="server" CssClass="Common_button" 
                                                      Text="Block" onclick="btnBlock_Click" /&gt;
                                              &lt;/ItemTemplate&gt;
                                          &lt;/asp:TemplateField&gt;
                                      &lt;/Columns&gt;
  
                                  &lt;/asp:GridView&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;`
  --------------------------------cs-: RowCommand---code--------------------------
  protected void dgvActivatedCustomers_RowCommand1(object sender, GridViewCommandEventArgs e)
    {
  
          //Load System details gridview in modalpop up...
          if(e.CommandName=="Select")
          {
               DataSet ds;
               int RowIndex = Convert.ToInt32(e.CommandArgument);
  
              long ProductSerialID = Convert.ToInt32(dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"]) ;
              hdnProuductId.Value= dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"].ToString();
  
               lblmessage1.Visible = true;
               //string RegStatus = dgvSystemDetails.SelectedRow.Cells[2].Text;
               string ProductSerial = dgvActivatedCustomers.Rows[RowIndex].Cells[6].Text;
               string Reg_Status = LoadSystemDetails(ProductSerialID).Tables[0].Rows[0]["Reg_Status"].ToString();
                  lblmessage1.Text = "Activation Code :" + General.GetActivationCode(Convert.ToDouble(ProductSerial)).ToString();
                  LoadSystemDetails(ProductSerialID);
                  ds = LoadSystemDetails(ProductSerialID);
              //filling data table
                  DataTable dt = (DataTable)dgvSystemDetails.DataSource;
  
              //Add new columns to datatable
                  dt.Columns.Add("Key", typeof(System.Int64));
  
              // get key for specific key by passing system code ot getRegistrationKey. 
                  for (int i = 0; i &lt; ds.Tables[0].Rows.Count; i++)
                  {
                      string SystemCode = ds.Tables[0].Rows[i]["SystemCode"].ToString();
                      //lblmessage2.Text = "Key :" + Registration.getRegistrationKey(SystemCode, ProductSerial);
  
                      string Key = Registration.getRegistrationKey(SystemCode, ProductSerial);
                      dt.Rows[i]["Key"] = Key;
                  }
  
                  Session["dgvSystemDetailsDataSource"] = dt;
                  dgvSystemDetails.DataSource = dt;
                  dgvSystemDetails.DataBind();
                  dgvSystemDetails.Visible = true;
  
  
                  if (Reg_Status == "Blocked")
                  {
                      lblmessage1.Visible = true;
                      lblmessage1.Text = "Blocked System";
                      //dgvSystemDetails.FindControl("btnBlock").Visible = false;
  
                      dgvSystemDetails.DataSource = Session["dgvSystemDetailsDataSource"]; 
                      dgvSystemDetails.DataBind();
  
                      ModalPopUp.Show();
                  }
                  ModalPopUp.Show();
          }
  
  }
  </code></pre>
  
  <p>description :btnclick second popup--------------</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      try
      {
          Button btn = (Button)sender;
          GridViewRow row = (GridViewRow)btn.NamingContainer;
          int rowno = row.RowIndex;
          txtFirstName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerName"].ToString();
          txtSecondName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerLName"].ToString();
          txtAddress1.Text = (dgvActivatedCustomers.Rows[rowno].Cells[4].Text != "&amp;nbsp;" ? dgvActivatedCustomers.Rows[rowno].Cells[4].Text : "");
  
          txtPhone.Text = (dgvActivatedCustomers.Rows[rowno].Cells[2].Text != "&amp;nbsp;" ? dgvActivatedCustomers.Rows[rowno].Cells[2].Text : "");
          txtMobile.Text = (dgvActivatedCustomers.Rows[rowno].Cells[3].Text != "&amp;nbsp;" ? dgvActivatedCustomers.Rows[rowno].Cells[3].Text : "");
          hdnId.Value = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerID"].ToString();
          txtName.Text = (dgvDemoCust.SelectedRow != "") ? dgvDemoCust.SelectedRow.Cells[0].Text : "";
  
  
          ModalPopupExtender1.Show();
      }
      catch (Exception ex) { }
  }
  </code></pre>
  
  <p>Question : The first pop up is showing but the second one doesn't.....any body have any idea</p>