简体   繁体   中英

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

I am trying to pass value from listbox in ModalPopupExtender to textbox in gridview footer row textbox in parent page. In the current scenario the application breaks on button click. I have tried using Javascript,juery and C# but all results in same. Does somebody has any suggestion on how to do this? Below is my code:

I am trying to Pass value from listbox "lst_PdfViewers" to gridview textbox "AddSupplierName" on Done button click event "btnSupplierDone_Click"

Gridview Footer row:

<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>

Popup Div having Listbox and Done Button:

<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 event

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

I get correct results when I switch these controls. You have:

lst_PdfViewers.SelectedValue = txtAddSupplierName.Text;

But if you want the value of lst_PdfViewers in the Footer row use:

txtAddSupplierName.Text = lst_PdfViewers.SelectedValue;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM