Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem in tranfer the value of one gridView cell into another gridview textbox

problem in tranfer the value of one gridView cell into another gridview textbox

Scheduled Pinned Locked Moved ASP.NET
helptutorial
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Spadez
    wrote on last edited by
    #1

    hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }

    K A 2 Replies Last reply
    0
    • A Amit Spadez

      hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }

      K Offline
      K Offline
      keyur satyadev
      wrote on last edited by
      #2

      have you a link or button to transfer the data of one grid cell value to other?

      Regards Keyur Satyadev

      A 1 Reply Last reply
      0
      • A Amit Spadez

        hello all, I want to get a value from gridView (grdQuestions) which in turn goes to the textbox which is in another grdView(grdOptions). Now, the problem is how to find the control of textBox(txtText) of "GrdOptions" GridView, so that i can set the "GrdQuestions" griview cells' value into that textbox... plz help if you understand.. The code is: foreach (GridViewRow rw in GrdQuestions.Rows) { for (int i = 8; i < GrdQuestions.Rows[e.NewEditIndex].Cells.Count; i++) { TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText"); if (GrdQuestions.Rows[rw.RowIndex].Cells[i].Text != string.Empty) { tb.Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text; } } }

        A Offline
        A Offline
        Amar Chaudhary
        wrote on last edited by
        #3

        Please use codeblock/code tags while copying code into the question. That will make it easy to read. And please also let me know what exception are you getting and if the grdOptions is binded at the time of this operation.

        It is Good to be Important but! it is more Important to be Good

        A 1 Reply Last reply
        0
        • K keyur satyadev

          have you a link or button to transfer the data of one grid cell value to other?

          Regards Keyur Satyadev

          A Offline
          A Offline
          Amit Spadez
          wrote on last edited by
          #4

          I have textbox in another gridview to which value is to be inserted But i don't know how transfer that value into that textbox

          K 1 Reply Last reply
          0
          • A Amar Chaudhary

            Please use codeblock/code tags while copying code into the question. That will make it easy to read. And please also let me know what exception are you getting and if the grdOptions is binded at the time of this operation.

            It is Good to be Important but! it is more Important to be Good

            A Offline
            A Offline
            Amit Spadez
            wrote on last edited by
            #5

            I just want to know how to get the value of one gridview row into the textbox which is in the template field of another gridview . could you help me in the code?

            A 1 Reply Last reply
            0
            • A Amit Spadez

              I have textbox in another gridview to which value is to be inserted But i don't know how transfer that value into that textbox

              K Offline
              K Offline
              keyur satyadev
              wrote on last edited by
              #6

              do one thing, when you fire the itemcommand on first gridview at that time take that textbox value in some field (such as if many fields then use the datatable ) and give that datatable to the second grid. i.e. grd2.datasource = dt; grd2.databind() protected void grd1_ItemCommand(object sender, GridCommandEventsArgs e) { if(e.commandname == "settextboxvalue") { string txt1value; txt1value = (TextBox)grd1.FindControl("txt1").Text; } } in this way you get the value of textbox of first grid now you can assign this to the second.

              Regards Keyur Satyadev

              1 Reply Last reply
              0
              • A Amit Spadez

                I just want to know how to get the value of one gridview row into the textbox which is in the template field of another gridview . could you help me in the code?

                A Offline
                A Offline
                Amar Chaudhary
                wrote on last edited by
                #7

                (GrdOptions.Rows[0].FindControl("txtText") as TextBox).Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text;

                I doubt that its not the way which is causing you problem but its the logic.

                It is Good to be Important but! it is more Important to be Good

                A 1 Reply Last reply
                0
                • A Amar Chaudhary

                  (GrdOptions.Rows[0].FindControl("txtText") as TextBox).Text = GrdQuestions.Rows[rw.RowIndex].Cells[i].Text;

                  I doubt that its not the way which is causing you problem but its the logic.

                  It is Good to be Important but! it is more Important to be Good

                  A Offline
                  A Offline
                  Amit Spadez
                  wrote on last edited by
                  #8

                  its not the correct way, how could you populate the row in the statement (GrdOptions.Rows[0].FindControl("txtText") as TextBox) as in that griview, row is empty thus, its giving an error "Index out of range"

                  A 1 Reply Last reply
                  0
                  • A Amit Spadez

                    its not the correct way, how could you populate the row in the statement (GrdOptions.Rows[0].FindControl("txtText") as TextBox) as in that griview, row is empty thus, its giving an error "Index out of range"

                    A Offline
                    A Offline
                    Amar Chaudhary
                    wrote on last edited by
                    #9

                    vinci007 wrote:

                    TextBox tb = (TextBox)GrdOptions.Rows[0].Cells[1].FindControl("txtText");

                    vs

                    vinci007 wrote:

                    (GrdOptions.Rows[0].FindControl("txtText") as TextBox)

                    Doesn't have much difference index out of range!! might have many reasons behind it. 1. your grid GrdOptions is not binded at all. 2. the data source is empty. Please provide more detail what do you want to accomplish - adding some more formatted code will help too.

                    It is Good to be Important but! it is more Important to be Good

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups