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. Getting column data from GridView on page using MasterPage

Getting column data from GridView on page using MasterPage

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netquestion
17 Posts 2 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.
  • G Grapes R Fun

    Nah, the Masterpage has nothing to do with this... just convert all your columns to templates (note that they will all default to Label controls; let me know if you need help with templated fields), then give your templated controls meaningful names. THEN you can access them like this: String _city; ... protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { ... Label city = (Label)(GridView1.SelectedRow.FindControl("cityLabel")); _city = city.Text; city.Dispose(); //yup, always clean up! TextBox copy = (TextBox)(GridView1.SelectedRow.FindControl("copyTextBox")); copy.Text = _city copy.Dispose(); } Give this a try. Let me know if it works ro not :-)

    Nila "...for that, I will need a large cup of coffee and a bran muffin!" -Samantha Bea

    M Offline
    M Offline
    marconi Flangepants
    wrote on last edited by
    #7

    Thanks Nila, Ill give it a try today, and ill let you know how it goes! ;-)

    1 Reply Last reply
    0
    • G Grapes R Fun

      Nah, the Masterpage has nothing to do with this... just convert all your columns to templates (note that they will all default to Label controls; let me know if you need help with templated fields), then give your templated controls meaningful names. THEN you can access them like this: String _city; ... protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { ... Label city = (Label)(GridView1.SelectedRow.FindControl("cityLabel")); _city = city.Text; city.Dispose(); //yup, always clean up! TextBox copy = (TextBox)(GridView1.SelectedRow.FindControl("copyTextBox")); copy.Text = _city copy.Dispose(); } Give this a try. Let me know if it works ro not :-)

      Nila "...for that, I will need a large cup of coffee and a bran muffin!" -Samantha Bea

      M Offline
      M Offline
      marconi Flangepants
      wrote on last edited by
      #8

      Mate I Loves Ya! That works perfectly!!! Thanks a lot. But perhaps you can tell me 1 thing? Why does it only work when passing the Controls Data to a variable and then onto the static label control, yet it doesnt work when i miss out the middle man and try getting the data from the dynamic label and adding it straight to the static label? Thanks again. I appreciate your time!

      G 1 Reply Last reply
      0
      • M marconi Flangepants

        Mate I Loves Ya! That works perfectly!!! Thanks a lot. But perhaps you can tell me 1 thing? Why does it only work when passing the Controls Data to a variable and then onto the static label control, yet it doesnt work when i miss out the middle man and try getting the data from the dynamic label and adding it straight to the static label? Thanks again. I appreciate your time!

        G Offline
        G Offline
        Grapes R Fun
        wrote on last edited by
        #9

        Oh I have no idea why... typically when something doesn't work, I find a work around and move-on. Im sure the 'corky' .Net has its reasons, I just don't have time/patience to figure out the WHY ;-) Now, what does Mate I Loves Ya! mean??

        Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

        M 1 Reply Last reply
        0
        • G Grapes R Fun

          Oh I have no idea why... typically when something doesn't work, I find a work around and move-on. Im sure the 'corky' .Net has its reasons, I just don't have time/patience to figure out the WHY ;-) Now, what does Mate I Loves Ya! mean??

          Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

          M Offline
          M Offline
          marconi Flangepants
          wrote on last edited by
          #10

          Grapes-R-Fun wrote:

          Now, what does Mate I Loves Ya! mean??

          Ive no idea. Its a work around i use on my Girlfriend for most situations Babe, i love you! Likewise i dont understand women or what they want. lol!! :confused::laugh:

          G 1 Reply Last reply
          0
          • M marconi Flangepants

            Grapes-R-Fun wrote:

            Now, what does Mate I Loves Ya! mean??

            Ive no idea. Its a work around i use on my Girlfriend for most situations Babe, i love you! Likewise i dont understand women or what they want. lol!! :confused::laugh:

            G Offline
            G Offline
            Grapes R Fun
            wrote on last edited by
            #11

            LOL- are u flirting with me? :-O

            Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

            M 1 Reply Last reply
            0
            • G Grapes R Fun

              LOL- are u flirting with me? :-O

              Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

              M Offline
              M Offline
              marconi Flangepants
              wrote on last edited by
              #12

              Grapes-R-Fun wrote:

              are u flirting with me?

              I wasnt until i saw your pic on your profile!:->

              G 1 Reply Last reply
              0
              • M marconi Flangepants

                Grapes-R-Fun wrote:

                are u flirting with me?

                I wasnt until i saw your pic on your profile!:->

                G Offline
                G Offline
                Grapes R Fun
                wrote on last edited by
                #13

                um, how did you see my pic? do you have one??;)

                Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

                M 1 Reply Last reply
                0
                • G Grapes R Fun

                  um, how did you see my pic? do you have one??;)

                  Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

                  M Offline
                  M Offline
                  marconi Flangepants
                  wrote on last edited by
                  #14

                  Your profile!

                  G 1 Reply Last reply
                  0
                  • M marconi Flangepants

                    Your profile!

                    G Offline
                    G Offline
                    Grapes R Fun
                    wrote on last edited by
                    #15

                    oh yeah, I figured how to see others' profiles as well... I am queen of the clueless nation!! why don't you put your pic up?

                    Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

                    M 1 Reply Last reply
                    0
                    • G Grapes R Fun

                      oh yeah, I figured how to see others' profiles as well... I am queen of the clueless nation!! why don't you put your pic up?

                      Nila "...for that, I will need a large cup of coffee and a brand muffin!" -Samantha Bea

                      M Offline
                      M Offline
                      marconi Flangepants
                      wrote on last edited by
                      #16

                      Grapes-R-Fun wrote:

                      why don't you put your pic up?

                      Are you flirting with me?

                      G 1 Reply Last reply
                      0
                      • M marconi Flangepants

                        Grapes-R-Fun wrote:

                        why don't you put your pic up?

                        Are you flirting with me?

                        G Offline
                        G Offline
                        Grapes R Fun
                        wrote on last edited by
                        #17

                        lol, maybe!

                        Nila I do ANYTHING for an extra large cup of coffee!

                        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