【问题标题】:How to pass value from ModalPopupExtender to Gridview footer row textbox on buttonclick如何在按钮单击时将值从 ModalPopupExtender 传递到 Gridview 页脚行文本框
【发布时间】:2018-09-02 09:42:18
【问题描述】:

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

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

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();
    }
}

【问题讨论】:

    标签: c# asp.net ajax popup modalpopupextender


    【解决方案1】:

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

    lst_PdfViewers.SelectedValue = txtAddSupplierName.Text;
    

    但如果您希望在页脚行中使用 lst_PdfViewers 的值,请使用:

    txtAddSupplierName.Text = lst_PdfViewers.SelectedValue;
    

    【讨论】:

    • 试过了,仍然是同样的问题,按钮点击时代码中断。
    猜你喜欢
    • 2021-01-27
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2012-01-21
    • 2017-06-22
    • 1970-01-01
    • 2012-01-24
    • 2018-03-01
    相关资源
    最近更新 更多