如何在gridview中弹出两个modalpopup

时间:2014-01-25 04:56:26

标签: c# asp.net gridview

我想从gridview中弹出两个modalpopup。我在网上搜索但找不到确切的答案。任何帮助表示赞赏。

--------ModalPopupExtender1---------

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
BackgroundCssClass="ModalPopupBG" CancelControlID="btn_Cancel" Drag="true" 
PopupControlID="Panel2" PopupDragHandleControlID="Panel2" 
TargetControlID="btnNew">
</asp:ModalPopupExtender>

-----------------PopupControlID="Panel2--------------------------
<div id="Panel2" class="popupConfirmation">
  <div class="popup_Container">
    <div id="PopupHeader" class="popup_Titlebar">
      <div class="TitlebarLeft">
        <%--
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        --%>
        Edit Customer
      </div>
      <!--
<div class="TitlebarRight" >
</div>
-->
                                      </div>
                                      <div>
                                        <table bgcolor="#CCFFFF" cellpadding="0" cellspacing="2" width="100%">
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td width="25%">
                                              &nbsp;
                                            </td>
                                            <td width="65%">
                                              &nbsp;
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              <asp:LabelID="lblName"runat="server"FontSize="11pt" Text="First Name:">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              <asp:TextBox ID="txtFirstName" runat="server" Width="300px">
                                              </asp:TextBox>
                                              <asp:Label ID="lbl_ErrorName" runat="server" ForeColor="Red" 
                                              style="display:none" Text="*">
                                              </asp:Label>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              <asp:Label ID="lblName2" runat="server" Font-Size="11pt" Text="Second Name:">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              <asp:TextBox ID="txtSecondName" runat="server" Width="300px">
                                              </asp:TextBox>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <%-- 
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="45%">
                                              <asp:Label ID="lblName0" runat="server" Font-Size="11pt" Text="City">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="45%">
                                              <asp:TextBox ID="txtCity" runat="server" Width="200px">
                                              </asp:TextBox>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="45%">
                                              <asp:Label ID="lblName1" runat="server" Font-Size="11pt" Text="State">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="45%">
                                              <asp:TextBox ID="txtState" runat="server" Width="200px">
                                              </asp:TextBox>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          --%>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              <asp:Label ID="lblAddress1" runat="server" Font-Size="11pt" Text="Address1:">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              <asp:TextBox ID="txtAddress1" runat="server" Width="300px">
                                              </asp:TextBox>
                                              <asp:Label ID="lbl_ErrorAddress1" runat="server" ForeColor="Red" 
                                              style="display:none" Text="*">
                                              </asp:Label>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <%-- 
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="45%">
                                              <asp:Label ID="lblAddress2" runat="server" Font-Size="11pt" Text="Address2:">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="45%">
                                              <asp:TextBox ID="txtAddress2" runat="server" Width="200px">
                                              </asp:TextBox>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          --%>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              <asp:Label ID="lblDOB" runat="server" Font-Size="11pt" Text="Phone">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              <asp:TextBox ID="txtPhone" runat="server" Width="200px">
                                              </asp:TextBox>


                                              <%--
                                              <asp:CalendarExtender ID="txt_DOB_CalendarExtender" runat="server" 
                                              TargetControlID="txt_DOB">
                                              </asp:CalendarExtender>
                                              --%>


                                              <asp:Label ID="lblErrorDOB" runat="server" Font-Bold="True" ForeColor="Red" 
                                              style="display:none" Text="*">
                                              </asp:Label>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              <asp:Label ID="lblDOB0" runat="server" Font-Size="11pt" Text="Mobile">
                                              </asp:Label>
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              <asp:TextBox ID="txtMobile" runat="server" Width="200px">
                                              </asp:TextBox>
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                          <tr>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: right" width="25%">
                                              &nbsp;
                                            </td>
                                            <td style="text-align: left" width="65%">
                                              &nbsp;
                                            </td>
                                            <td width="5%">
                                              &nbsp;
                                            </td>
                                          </tr>
                                        </table>
                                      </div>
                                      <div align="center">
                                        &nbsp;
                                        <asp:Button ID="btn_Update" runat="server"  
                                        Text="Save" Width="75px" onclick="btn_Update_Click" />
                                        <asp:Button ID="btn_Cancel" runat="server" Text="Cancel" Width="75px" />
                                        &nbsp;
                                      </div>
      </div>
</div>
----------------`ModalpopUp`----------------------------
         <asp:ModalPopupExtender ID="ModalPopUp" runat="server" 
                            CancelControlID="idclose" Drag="true" DynamicServicePath="" Enabled="True" 
                            PopupControlID="PartyCustomers_idbody" 
                            PopupDragHandleControlID="PartyCustomers_IdTitle" 
                            TargetControlID="btnShowPopup">
                            <Animations>
            <OnShown><Fadein Duration="0.50" /></OnShown>
            <OnHiding><Fadeout Duration="0.75" /></OnHiding>
        </Animations>
                        </asp:ModalPopupExtender>
--------------------PartyCustomers_idbody : popupbody--------------
`<div id="PartyCustomers_idbody" runat="server" class="Common_divbody" 
                            >
                            <div id="PartyCustomers_IdTitle" runat="server" class="Common_divtitle" 
                                >
                                <div id="idclose" class="Common_close">
                                </div>
                                <div class="Common_divhr">
                                    Booked Status</div>
                            </div>
                            <div class="ModalPopUpDiv">
                            <asp:Label ID="lblmessage1" runat="server" Text="Label"></asp:Label>
                                &nbsp;
                                <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">
                                    <AlternatingRowStyle CssClass="alt" />
                                    <Columns>
                                        <asp:BoundField DataField="RegistrationDate" DataFormatString="{0:d}" 
                                            HeaderText="Registration Date">
                                        <HeaderStyle />
                                        <ItemStyle />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="SystemCode" HeaderText="System Code" />
                                        <asp:BoundField DataField="Reg_Status" HeaderText="Reg. Status" />
                                        <asp:BoundField DataField="Key" HeaderText="Key" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:Button ID="btnBlock" runat="server" CssClass="Common_button" 
                                                    Text="Block" onclick="btnBlock_Click" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>

                                </asp:GridView>
                            </div>
                        </div>`
--------------------------------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 < 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();
        }

}

描述:btnclick第二次弹出--------------

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 != "&nbsp;" ? dgvActivatedCustomers.Rows[rowno].Cells[4].Text : "");

        txtPhone.Text = (dgvActivatedCustomers.Rows[rowno].Cells[2].Text != "&nbsp;" ? dgvActivatedCustomers.Rows[rowno].Cells[2].Text : "");
        txtMobile.Text = (dgvActivatedCustomers.Rows[rowno].Cells[3].Text != "&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) { }
}

问题:第一个弹出窗口正在显示,但第二个弹出窗口没有.....任何机构都有任何想法

0 个答案:

没有答案