如何从另一个页面上的TextBox中的Gridview获取所选行的值 [英] How to get the Values of Selected Row from a Gridview in TextBox on another page

查看:90
本文介绍了如何从另一个页面上的TextBox中的Gridview获取所选行的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在文本框中成功获取所选值,该页面位于同一页面上,但现在我希望选定的列表显示在另一页面的文本框中。请帮忙。





i am able to get the selected value in textbox successfully which is on same page but, now I want that selected coloumn to be displayed in textbox of another page. Please help.


I think it is possible with the help of sessions.

now look i have two pages. On "page1.aspx" i have a button onclick grid pops up. that grid is on "page2.aspx"

it popup using iframes. Now what i want is to select particular column and that column should be displayed in textbox which is on page1.aspx

推荐答案

您可以使用JavaScript window.parent对象来访问iframe父页面。以下是供您参考的样本。



Page1.aspx

You can use JavaScript window.parent object to access iframe parent page. Below is sample for you reference.

Page1.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <iframe id="frame1" src='Page2.aspx' />
    </div>
    </form>
</body>
</html>





Page2.aspx



Page2.aspx

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" onkeyup="SetParentValue()"></asp:TextBox>
    </div>
    </form>
    <script>
        function SetParentValue() {
             parent.document.getElementById("TextBox1").value = document.getElementById("TextBox1").value;
        }
    </script>
    
</body>
</html>


这篇关于如何从另一个页面上的TextBox中的Gridview获取所选行的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆