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. Fetching data from gridview to label in another form.

Fetching data from gridview to label in another form.

Scheduled Pinned Locked Moved ASP.NET
csharpquestion
11 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.
  • B blurMember

    In C#, .NET 2.0. I have a gridview in frm_Report which looks like this. i have used the sqldatasource to bind the data. In my another form frm_Show is basically this. When user select the hyperlink View, the hyperlink will grab value of Stud_Admin of the selected row in gridview and display it at Label1. What is the next code should I add? thanks in advance. Much appreciated.

    J Offline
    J Offline
    Jay_se
    wrote on last edited by
    #2

    use Row.RowIndex property to get the selected row.. use RowCommand event of GridView.

    Regards, Jay

    B 1 Reply Last reply
    0
    • J Jay_se

      use Row.RowIndex property to get the selected row.. use RowCommand event of GridView.

      Regards, Jay

      B Offline
      B Offline
      blurMember
      wrote on last edited by
      #3

      I don't know what to do next. By getting the values, how will the hyperlink be clever to pass value to label in another form. And what is the syntax for Label1.text = ? By using findcontrol? And protected void GridView8_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = GridView8.Rows[0]; }

      thanks in advance. Much appreciated.

      1 Reply Last reply
      0
      • B blurMember

        In C#, .NET 2.0. I have a gridview in frm_Report which looks like this. i have used the sqldatasource to bind the data. In my another form frm_Show is basically this. When user select the hyperlink View, the hyperlink will grab value of Stud_Admin of the selected row in gridview and display it at Label1. What is the next code should I add? thanks in advance. Much appreciated.

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #4

        If the Stud_Admin text is simple, you may consider passing the value along with the url in the query string (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )so that you can get it from the Request object in the next page . In addition, you still have many other choices: + Try to retrieve again in DB based on the id passed from the source page when the text is long. + Try to use the LinkButton, so before redirecting to the next page you can save the text in the Session.

        B 1 Reply Last reply
        0
        • M minhpc_bk

          If the Stud_Admin text is simple, you may consider passing the value along with the url in the query string (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )so that you can get it from the Request object in the next page . In addition, you still have many other choices: + Try to retrieve again in DB based on the id passed from the source page when the text is long. + Try to use the LinkButton, so before redirecting to the next page you can save the text in the Session.

          B Offline
          B Offline
          blurMember
          wrote on last edited by
          #5

          :-D Thank you. It works.

          minhpc_bk wrote:

          (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )

          But I was just wondering what does Stud_Admin={0} means? If I want to pass two values which is Stud_admin and the next column just next to Stud_Admin? What will the longer DataNavigateUrlFormatString = be?

          thanks in advance. Much appreciated.

          M 1 Reply Last reply
          0
          • B blurMember

            :-D Thank you. It works.

            minhpc_bk wrote:

            (set this DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}" )

            But I was just wondering what does Stud_Admin={0} means? If I want to pass two values which is Stud_admin and the next column just next to Stud_Admin? What will the longer DataNavigateUrlFormatString = be?

            thanks in advance. Much appreciated.

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #6

            HyperLinkField.DataNavigateUrlFormatString Property[^]

            B 1 Reply Last reply
            0
            • M minhpc_bk

              HyperLinkField.DataNavigateUrlFormatString Property[^]

              B Offline
              B Offline
              blurMember
              wrote on last edited by
              #7

              I still don't understand.:(( I am using codebehind. And initially i can fetch one data from the gridview to another webform and display it in the label. I want to experiment and fetch two datas from the gridview to another webform and display it in the label. And another webform at the page load, Label1.Text = Request.QueryString["Stud_Admin"]; How can I fetch the Stud_Name as well and display it in Label2.text? thanks in advance. Much appreciated.

              M 1 Reply Last reply
              0
              • B blurMember

                I still don't understand.:(( I am using codebehind. And initially i can fetch one data from the gridview to another webform and display it in the label. I want to experiment and fetch two datas from the gridview to another webform and display it in the label. And another webform at the page load, Label1.Text = Request.QueryString["Stud_Admin"]; How can I fetch the Stud_Name as well and display it in Label2.text? thanks in advance. Much appreciated.

                M Offline
                M Offline
                minhpc_bk
                wrote on last edited by
                #8

                Well, the explanation in MSDN is clear enough: +DataNavigateUrlFields="Stud_Admin,Stud_Name" (seperated by comma) +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)

                B 1 Reply Last reply
                0
                • M minhpc_bk

                  Well, the explanation in MSDN is clear enough: +DataNavigateUrlFields="Stud_Admin,Stud_Name" (seperated by comma) +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)

                  B Offline
                  B Offline
                  blurMember
                  wrote on last edited by
                  #9

                  Thanks many-many.

                  minhpc_bk wrote:

                  +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)

                  Though this should be right, DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={1}"

                  thanks in advance. Much appreciated.

                  M 1 Reply Last reply
                  0
                  • B blurMember

                    Thanks many-many.

                    minhpc_bk wrote:

                    +DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={0}" (the parameters in the url are seperated by the &)

                    Though this should be right, DataNavigateUrlFormatString="frm_StudReport.aspx?Stud_Admin={0}&Stud_Name={1}"

                    thanks in advance. Much appreciated.

                    M Offline
                    M Offline
                    minhpc_bk
                    wrote on last edited by
                    #10

                    Ahh, that's my trap to challenge you ;P. Oops, my copy-paste error

                    B 1 Reply Last reply
                    0
                    • M minhpc_bk

                      Ahh, that's my trap to challenge you ;P. Oops, my copy-paste error

                      B Offline
                      B Offline
                      blurMember
                      wrote on last edited by
                      #11

                      :mad: I solved and solved, luckily I can solved. GOOd one over there! :laugh:

                      please be careful newbies. haha.

                      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