Urgent Help! How to get data from child's gridview to parent's textbox

 Hello Sir,

Would you please advise me, how can I get the data from child gridview to parent textbox.

For example, I have select 2 row in child's datagrid the values are "A" and "B" then click add and "A B" appears in the same parent's textbox.

Thanks in advance!

 

0
Novox
11/21/2008 6:33:48 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
854 Views

Similar Articles

[PageSpeed] 35

 Anyone please help me. How to get the data from gridview on popup page to textbox on the main page.

 

Thank you so much!!!!

0
Novox
11/22/2008 3:47:41 PM

Hi Novox ,

Please check my sample :

 

        <asp:GridView ID="GridView1" runat="server" Height="227px" Width="411px" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text="changerate"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

    <script>
      function openpage(targetTextBox) 
    {
        var newwin=window.open('newwin.aspx?target='+targetTextBox+'',"newWin","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,top=100,left=200,width=650,height=300");
        newwin.focus();
        return false;
    }

    </script>
  
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (Request["id"] != null)
            //    Response.Write(Request["id"]);
            DataTable table = new DataTable();
            table.Columns.Add("rate");
            table.Columns.Add("change");
            DataRow dr = table.NewRow();
            dr["rate"] = 1;
            dr["change"] = "change";
            table.Rows.Add(dr);

            DataRow dr2 = table.NewRow();
            dr2["rate"] = 2;
            dr2["change"] = "change";
            table.Rows.Add(dr2);

            this.GridView1.DataSource = table;
            GridView1.DataBind();
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label fire = (Label)e.Row.FindControl("Label1");

                TextBox toshow = (TextBox)e.Row.FindControl("TextBox1");
                
                fire.Attributes.Add("onclick", "openpage('"+toshow.ClientID+"');");

            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

  

Then , the popup window :

 

    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </div>

    <script>
        function ReKey(targetTextBox,content)
{
    
    window.opener.document.getElementById(targetTextBox).value=content.value;
    //window.opener.location = "Default.aspx?id="+document.getElementById('TextBox1').value;
    window.close();
}
    </script>
  
       //function ReKey(targetTextBox,content)
        protected void Page_Load(object sender, EventArgs e)
        {
            string targetTextBox = Request["target"];
            this.Button1.Attributes.Add("onclick", "ReKey('" + targetTextBox + "',document.getElementById('"+this.TextBox1.ClientID+"'))");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }

 

 



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
11/25/2008 3:27:26 AM

 I have read your code but not tested yet. One question is this code add the value into gridview's textbox in gridview item template?

0
Novox
11/25/2008 9:00:40 AM

Hi Novox ,

Yes, and it retrieve the value from child window.

 



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
11/27/2008 9:34:18 AM
Reply:

Similar Artilces:

Urgent Help! How to get data from child's gridview to parent's textbox #2
 Hello Sir,Would you please advise me, how can I get the data from child gridview to parent textbox?For example, I have select 2 row in child's datagrid the values are "A" and "B" then click add and "A B" appears in the parent's textbox. I think this must use JavaScript to make this happen but I have no idea, please help! Thanks in advance!  parent page : <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form...

Replace 1's and 0's in a gridview column with Yes's and No's
Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.  Thanks One way you can do is thrrough  CASE in your select statement: Select YesNoColumn= CASE yourColumn WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END FROM YourtableLimno <Columns>     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField"> ...

Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!
I write a datagrid's ItemDataBound method as follows:   private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)  {   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)   {    if(!isRole("Manager"))    {     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");     if(tmp.Text == "Passed")     {      ((LinkBu...

obtain ANY control's (textbox/dropdown) value in GridView's HeaderTemplate
Given this templated GridView column containing either Textbox's or DropDownLists......          <asp:TemplateField >              <HeaderTemplate>                      <asp:TextBox ID="TextBoxWellName" runat="server"  Visible="False" l"></asp:TextBox>           &nb...

Ajaxmodalpopup TextBox's --> TEXT--> GridView's TextBox
  Hi I have A Problem With my javascript,   ERROR: 'txtbox1' is undefine in javascript What i want to achieve: I have 1 textbox in my Gridview and i have Modalpopup, i want to transfer data from modalpopup to Gridview's Textbox like User will enter Text into modalpopup's Textbox and Text should go to Gridview's Textbox  for that i have below code:  CODE BEHIND:  For Each gvr As GridViewRow In GridView2.Rows 'Get a programmatic reference to the CheckBox control 'Dim cb As CheckBox = CType(gvr.FindControl("chkBox1"), Ch...

TabContainer's height doesn't respecting child GridView's height
Well, it's not that complex:I have a TabContainer with 4 tabs. In the first 2 I have different GridViews, but I'm actually only working with the first one.There's no UpdatePanel, no crazy situations, it's a simple GridView with an associated ObjectDataSource, wich will DataBind the GridView in every PostBack (yes, normal, simple, server-side PostBack) based on the value of a TextBox. And this value is only changed on the click of a ImageButton. All of this happens on the Server side.BUT, in the initial load of the page, the GridView is empty, as is the TabPanel. After the fir...

How can I get out of my Mozilla's browser the Winamp browser and get back the Google's or Mozilla's browser.
Please I have got to my browser ( I don't know how.) the Winamp browser he behave like virus stick in.But he doesn't has uninstalation section so I can't do anything to get him away from Mozilla's file. I'm not happy of Winamp's behave its like advertisement against a customer's will. Please is there any way to get him away from Mozilla?Please send me exact direction I have tried many ways but he is deeply inside the systeme so when I install new Mozilla he is always here ready to pester me. Thank you for an answer. Richard ...

The value's length for key 'data source' exceeds it's limit of '128'.
Hii, When I tried to bind dropdownlist to database by declaring connection string in the code behind file I am getting this error: The value's length for key 'data source' exceeds it's limit of '128'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The value's length for key 'data source' exceeds it's limit of '128'.Source Error: An...

superreview requested: [Bug 408749] "ASSERTION: A block's child' s next in flow's parent must be a block" with -moz-column, table stuff : [ Attachment 293607] fix assert
Robert O'Callahan (:roc) <roc@ocallahan.org> has asked Boris Zbarsky (reviews very slow until spring) <bzbarsky@mit.edu> for superreview: Bug 408749: "ASSERTION: A block's child's next in flow's parent must be a block" with -moz-column, table stuff https://bugzilla.mozilla.org/show_bug.cgi?id=408749 Attachment 293607: fix assert https://bugzilla.mozilla.org/attachment.cgi?id=293607&action=edit ------- Additional Comments from Robert O'Callahan (:roc) <roc@ocallahan.org> This patch creates nsBlockFrame* nsLayoutUtils::GetAsBlock wh...

superreview granted: [Bug 408749] "ASSERTION: A block's child' s next in flow's parent must be a block" with -moz-column, table stuff : [ Attachment 293607] fix assert
Boris Zbarsky (reviews very slow until spring) <bzbarsky@mit.edu> has granted Robert O'Callahan (:roc) <roc@ocallahan.org>'s request for superreview: Bug 408749: "ASSERTION: A block's child's next in flow's parent must be a block" with -moz-column, table stuff https://bugzilla.mozilla.org/show_bug.cgi?id=408749 Attachment 293607: fix assert https://bugzilla.mozilla.org/attachment.cgi?id=293607&action=edit ------- Additional Comments from Boris Zbarsky (reviews very slow until spring) <bzbarsky@mit.edu> Looks good. That said, s...

superreview granted: [Bug 408749] "ASSERTION: A block's child' s next in flow's parent must be a block" with -moz-column, table stuff : [ Attachment 293637] reflow captions with unconstrained height
Boris Zbarsky (reviews very slow until spring) <bzbarsky@mit.edu> has granted Robert O'Callahan (:roc) <roc@ocallahan.org>'s request for superreview: Bug 408749: "ASSERTION: A block's child's next in flow's parent must be a block" with -moz-column, table stuff https://bugzilla.mozilla.org/show_bug.cgi?id=408749 Attachment 293637: reflow captions with unconstrained height https://bugzilla.mozilla.org/attachment.cgi?id=293637&action=edit ...

superreview requested: [Bug 408749] "ASSERTION: A block's child' s next in flow's parent must be a block" with -moz-column, table stuff : [ Attachment 293637] reflow captions with unconstrained height
Robert O'Callahan (:roc) <roc@ocallahan.org> has asked Boris Zbarsky (reviews very slow until spring) <bzbarsky@mit.edu> for superreview: Bug 408749: "ASSERTION: A block's child's next in flow's parent must be a block" with -moz-column, table stuff https://bugzilla.mozilla.org/show_bug.cgi?id=408749 Attachment 293637: reflow captions with unconstrained height https://bugzilla.mozilla.org/attachment.cgi?id=293637&action=edit ------- Additional Comments from Robert O'Callahan (:roc) <roc@ocallahan.org> Fixes the assertion independen...

It's Linux !? No, it's BSD ! No, no, it's...
kFreeBSD http://wiki.debian.org/Debian_GNU/kFreeBSD a Debian distro using the FreeBSD kernel ! ObiWan wrote: > kFreeBSD > > http://wiki.debian.org/Debian_GNU/kFreeBSD > > a Debian distro using the FreeBSD kernel ! Why use a BSD kernel? I hope the reason is more than, just because they can. http://wiki.debian.org/Debian_GNU/kFreeBSD_why It's easy to understand why the would want to use Debian packages. :) -- Jimmy Johnson Registered Linux User #380263 >> kFreeBSD >> >> http://wiki.debian.org/Debian_GNU/kFreeBSD >> ...

how to control a RadioButtonList's Listitem's text show according database's field
Hi my page has a repeater control,in repeater has a RadioButtonList control now i want to let the RadioButtonList has four Listitem,every Listitem's text is a database's field so the listitem can show dynamic according every record how can i work out my problem thanks a lot  hello dearbound your RadioButtonList to database if i m not clear fell free 4 replySatyabrat SinghB.E.(C.Sc.)Web developer Livetek Solution Dont forget to click "Mark as Answer" on the post that helped you. yes.i bound the radiobuttonlist to a dataset but how to display the ...

Web resources about - Urgent Help! How to get data from child's gridview to parent's textbox - asp.net.presentation-controls

Resources last updated: 12/5/2015 1:08:01 PM