Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3346922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:21:39+00:00 2026-05-18T01:21:39+00:00

I wrote a modelpopup which displays a gridview. The gridview loads and the data’s

  • 0

I wrote a modelpopup which displays a gridview. The gridview loads and the data’s are displayed perfectly now i want to select a row and it should pass the values to a couple of textbox which is in the page, from where i opened the popup.

//default.aspx

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
   <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"
        EnableScriptLocalization="true">
    </asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:Button ID="btnclear" runat="server" CssClass="LPS_Button" Text="Clear" OnClick="btnclear_Click" />
    <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
    <cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
        PopupControlID="pnlCities" CancelControlID="btnClose" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="pnlCities" runat="server" Style="background-color: White; border-color: Black;
        border-style: solid; border-width: thin;" SkinID="PopUpPanel">
        <asp:UpdatePanel ID="upCities" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Label ID="lblCities" runat="server" Text="Search Result" SkinID="Heading"></asp:Label><br />
                <asp:GridView ID="gvsearch" CssClass="LPS_DataGrid" runat="server" AllowPaging="True"
                    AutoGenerateColumns="False" CellPadding="4" GridLines="None" Height="100%" OnPageIndexChanging="gvsearch_PageIndexChanging"
                    PageSize="5" ShowFooter="True" Width="100%" OnRowCommand="gvsearch_RowCommand">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:TemplateField HeaderText="ID">
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkid" runat="server" Text='<%# Bind("ID") %>'></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Name">
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkname" runat="server" Text='<%# Bind("Name") %>'></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Select">
                            <ItemTemplate>
                                <asp:Button ID="btgselect" runat="server" Text="Select" CommandName="Select" CommandArgument='<%# Eval("ID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle />
                    <FooterStyle CssClass="LPS_Grid_FooterStyle" />
                    <PagerStyle CssClass="LPS_Grid_PageStyle" />
                    <SelectedRowStyle CssClass="LPS_Grid_SelectedRowStyle" />
                    <HeaderStyle CssClass="LPS_Grid_HeaderStyle" />
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <div style="text-align: center; width: 100%; margin-top: 5px;">
            <asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" />
        </div>
    </asp:Panel>
</asp:Content>

// default.aspx.cs coding

protected void btnclear_Click(object sender, EventArgs e)
{
    popup();
    //Session["tablename"] = "Vendor";
    //Response.Write("<script language='javascript'>window.open('Search.aspx',null,'height=450, width=450,status= no, resizable= no, scrollbars=yes, toolbar=no,location=no,menubar=no ');</script>");        
}
protected void gvsearch_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    popup();
    gvsearch.PageIndex = e.NewPageIndex;
    gvsearch.DataBind();
}
void popup()
{
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    popupsearch pop = new popupsearch();
    XmlDocument xmlsearch = new XmlDocument();
    XmlElement xmlroot = xmlsearch.CreateElement("Search");
    XmlElement xmlsearchs = xmlsearch.CreateElement("Popup");
    xmlsearchs.SetAttribute("tablename", "employee");
    xmlroot.AppendChild(xmlsearchs);
    xmlsearch.AppendChild(xmlroot);
    ds = pop.search(xmlsearch);
    dt = ds.Tables.Add("list");
    dt.Columns.Add("ID", Type.GetType("System.String"));
    dt.Columns.Add("Name", Type.GetType("System.String"));
    DataRow myRow;
    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
    {
        if (ds.Tables[0].Rows.Count > 0)
        {
            myRow = dt.NewRow();
            myRow["ID"] = ds.Tables[0].Rows[i][0].ToString();
            myRow["Name"] = ds.Tables[0].Rows[i][1].ToString();
            dt.Rows.Add(myRow);
        }
    }
    gvsearch.DataSource = ds.Tables["list"];
    gvsearch.DataBind();
    upCities.Update();
    mdlPopup.Show();
}
protected void gvsearch_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        TextBox1.Text = e.CommandArgument.ToString();
    }
}

please friends help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:21:40+00:00Added an answer on May 18, 2026 at 1:21 am

    Put your text boxes inside an UpdatePanel whose UpdateMode property is set to Always:

    <asp:UpdatePanel ID="upTextBoxes" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        </ContentTemplate>
    </asp:UpdatePanel>
    

    That way, your text boxes will be refreshed when the grid view performs an asynchronous postback.

    EDIT: If you also want to close the modal popup, do that server-side when you update your text boxes:

    protected void gvsearch_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select") {
            TextBox1.Text = e.CommandArgument.ToString();
            mdlPopup.Hide();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a windows service using VB that read some legacy data from Visual
I wrote a component that displays a filename, a thumbnail and has a button
I wrote a simple Windows Forms program in C#. I want to be able
I wrote a Perl program to capture a live data stream from a tail
I wrote two applictions which comunicate by socket. This is the code: Server: import
I wrote a website, with several pages, in PHP and now need it translated
I wrote a program, which open docx package and changes some <w:t> -text in
I wrote the following stored procedure, in which I use a local variable 'syncParam':
Wrote the following in PowersHell as a quick iTunes demonstration: $iTunes = New-Object -ComObject
I wrote a simple batch file as a PowerShell script, and I am getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.