如何在单击按钮时将值从 ModalPopupExtender 传递到 Gridview 页脚行文本框

How to pass value from ModalPopupExtender to Gridview footer row textbox on buttonclick

我正在尝试将值从 ModalPopupExtender 中的列表框传递到父页面中 gridview 页脚行文本框的文本框。在当前场景中,应用程序在单击按钮时中断。我尝试过使用 Javascript、juery 和 C#,但所有结果都相同。有人对如何执行此操作有任何建议吗?下面是我的代码:

我正在尝试在完成按钮单击事件中将值从列表框 "lst_PdfViewers" 传递到 gridview 文本框 "AddSupplierName" "btnSupplierDone_Click"

Gridview 页脚行:

<FooterTemplate>                
     <asp:TextBox ID="AddSupplierName" runat="server"  >                                                             
          </asp:TextBox>
     <asp:ImageButton ID="btnlnkSupplier" runat="server" ImageUrl="../images/openDialog20.gif" 
         onclick ="lnkSupplier_Click"  /> 
 </FooterTemplate>

ModalPopupExtender:

<act:ModalPopupExtender ID="ModalPopupExtenderSupplier" CancelControlID="SupplierPopupCancel"  TargetControlID="Sample" 
   PopupControlID="Pnl_Pdfviewers" runat="server" Enabled="true"> </act:ModalPopupExtender>

具有列表框和完成按钮的弹出窗口 Div:

<div id="Pnl_Pdfviewers" style="display: none; width: 500px !important; height: 400px !important;"
    class="popupConfirmation">
    <div class="popup_Titlebar" id="div3">
        <div class="TitlebarRight" onclick="$get('SupplierPopupCancel').click();">
        </div>
    </div>
    <div id="div4" class="popup_Container popup_Body" style="overflow: auto; height: 125px;">
        <table id="Table2" class="table" style="table-layout: fixed; width: 450px;">
            <tr>
                <td style="word-wrap: break-word;">
                    <asp:ListBox ID="lst_PdfViewers" Width="250px" runat="server" OnSelectedIndexChanged="lst_PdfViewers_SelectedIndexChanged"></asp:ListBox>
                </td>
            </tr>
            <tr>
                <td style="word-wrap: break-word;">
                    <%--<input type="button" id="btn1"   OnClick="btnSupplierDone_Click" value="Client Button" />--%>
                    <asp:Button ID="BtnSupplierDone" runat="server" CausesValidation="False" OnClick="btnSupplierDone_Click" Text="Done" />
                </td>
            </tr>
        </table>
    </div>
</div>

.cs btnSupplierDone_Click 事件

protected void btnSupplierDone_Click(object sender, EventArgs e)
{
    if (lst_PdfViewers.SelectedValue != null)
    {
        var footerRow = gvPITransactionData.FooterRow;
        var txtAddSupplierName = (TextBox)footerRow.FindControl("AddSupplierName");
        lst_PdfViewers.SelectedValue = txtAddSupplierName.Text;
        // ModalPopupExtenderSupplier.Hide();
    }
}

当我切换这些控件时,我得到了正确的结果。你有:

lst_PdfViewers.SelectedValue = txtAddSupplierName.Text;

但是如果您想要在页脚行中使用 lst_PdfViewers 的值,请使用:

txtAddSupplierName.Text = lst_PdfViewers.SelectedValue;