Click here to Skip to main content
12,949,816 members (68,523 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i have a gridview control in that i have all the textboxes and out side the gridview i have one more textbox, what ever the value that i enter in the textbox i want to display that value in gridview textboxes

this is my code
<asp:TextBox ID="TextBox1" runat="server">
<asp:GridView ID="GridView1" runat="server">
<asp:TemplateField HeaderText="Maxmarks">
                                   <asp:TextBox ID="TextBox2" runat="server" Text='<%=(TextBox1.Text) %>'></asp:TextBox>

this is what i have written

thank you in advance
Posted 23-Nov-12 0:29am
Updated 23-Nov-12 1:58am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Fire the TextChanged event in the TextBox1.
More information here[^].
ChrisBoshoff.Net 23-Nov-12 6:55am
Wouldnt this rebind the grid in order to get the desired effect...i may be mistaken? I would prefer to make a javascript method that fires on a client side OnKeyPress event on the text box (Add the attribute on first load). This method would then itterate through the grid view children controls and alter the text of the matching _TextBox2 controls.
digimanus 23-Nov-12 7:41am
Yes it rebinds but when using caching (for example) it won't be that bad. Client side is an option too.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

the following solution may helpful for you....

don't set the Text Property of your inner Testbox .

protected void btnEnter_Click(object sender, EventArgs e)
          //comment-use this commented code if you have to set value of textbax  for perticullar row
          //rowNumber = 0
          //GridViewRow row = (GridViewRow)grvTest.Rows[rowNumber];
          //TextBox txt = (TextBox)row.FindControl("txtTextBoxInGrid");
          //txt.Text = txtTextBoxOutsideGrid.Text;
          // use this code to set value of all text boxes in gridview
          foreach (GridViewRow row in grvTest.Rows)
              TextBox txt = (TextBox)row.FindControl("txtTextBoxInGrid");
              txt.Text = txtTextBoxOutsideGrid.Text;
mahesh_chs 23-Nov-12 7:17am
Thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,749
CHill60 3,380
Maciej Los 2,953
Jochen Arndt 1,935
ppolymorphe 1,820

Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100