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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Get specific value from DetailsView

Get specific value from DetailsView

Scheduled Pinned Locked Moved ASP.NET
cssquestion
7 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.
  • A Offline
    A Offline
    armasramirez
    wrote on last edited by
    #1

    Hi I´m trying to retrieve a value from an specific cell on a DetailsView grid and display it into a TextBox. I´m using something like TextBox1.Text=DetailsView.Row(1).Cell(1).Text but when I run the page, the value is not displayed. Any ideas?? Thanks

    E 1 Reply Last reply
    0
    • A armasramirez

      Hi I´m trying to retrieve a value from an specific cell on a DetailsView grid and display it into a TextBox. I´m using something like TextBox1.Text=DetailsView.Row(1).Cell(1).Text but when I run the page, the value is not displayed. Any ideas?? Thanks

      E Offline
      E Offline
      EssamDev
      wrote on last edited by
      #2

      hi your code is correct and i tried it under a button,the page runs without errors. tell me where you put your code? if you put it in load event,take care because you will have an error if the detailsview isn't filled in load event. try your code in button click event. thanks Essam Moustafa

      A 1 Reply Last reply
      0
      • E EssamDev

        hi your code is correct and i tried it under a button,the page runs without errors. tell me where you put your code? if you put it in load event,take care because you will have an error if the detailsview isn't filled in load event. try your code in button click event. thanks Essam Moustafa

        A Offline
        A Offline
        armasramirez
        wrote on last edited by
        #3

        I need it to ve retrieved when another control (A DropDownList) is executed...it is: 1) Element from DropDownList is selected 2) Then DetailsView displays something related to the element above 3) Then DetialsView value in Row(1) Cell(1) is displayed in TextBox

        E 1 Reply Last reply
        0
        • A armasramirez

          I need it to ve retrieved when another control (A DropDownList) is executed...it is: 1) Element from DropDownList is selected 2) Then DetailsView displays something related to the element above 3) Then DetialsView value in Row(1) Cell(1) is displayed in TextBox

          E Offline
          E Offline
          EssamDev
          wrote on last edited by
          #4

          hi after you fill your control as(listbox) you put this code in ListBox1_SelectedIndexChanged sqlconnection cn=new sqlconnection(); cn.ConnectionString = conString; SqlCommand cmd1 = new SqlCommand("select * from myTable where ID="+ListBox1.SelectedValue.ToString(), cn); SqlDataAdapter ad = new SqlDataAdapter(cmd1); dataset ds=new dataset(); ad.Fill(ds, "v"); DetailsView1.DataSource = ds.Tables["v"]; DetailsView1.DataBind(); TextBox1.Text = DetailsView2.Rows[1].Cells[1].Text; you can replace listbox with dropdownlist your brother Essam Moustafa

          A 1 Reply Last reply
          0
          • E EssamDev

            hi after you fill your control as(listbox) you put this code in ListBox1_SelectedIndexChanged sqlconnection cn=new sqlconnection(); cn.ConnectionString = conString; SqlCommand cmd1 = new SqlCommand("select * from myTable where ID="+ListBox1.SelectedValue.ToString(), cn); SqlDataAdapter ad = new SqlDataAdapter(cmd1); dataset ds=new dataset(); ad.Fill(ds, "v"); DetailsView1.DataSource = ds.Tables["v"]; DetailsView1.DataBind(); TextBox1.Text = DetailsView2.Rows[1].Cells[1].Text; you can replace listbox with dropdownlist your brother Essam Moustafa

            A Offline
            A Offline
            armasramirez
            wrote on last edited by
            #5

            This is not longer workin =( Maybe I need to declare a library or something, somehow???

            A 1 Reply Last reply
            0
            • A armasramirez

              This is not longer workin =( Maybe I need to declare a library or something, somehow???

              A Offline
              A Offline
              armasramirez
              wrote on last edited by
              #6

              the thing is that DetailsView control does not executes AutoPostBack, so the value in it is never passed to the TextBox ...??

              E 1 Reply Last reply
              0
              • A armasramirez

                the thing is that DetailsView control does not executes AutoPostBack, so the value in it is never passed to the TextBox ...??

                E Offline
                E Offline
                EssamDev
                wrote on last edited by
                #7

                hi my brother the code that i wrote is in c# you can convert it in vb.net easily. you don't need that the detailsview is postback or not because the code that i wrote can be implemented in ListBox Or DropDownList_SelectedIndexChanged Event if you try my code your problem will be solved. Essam Moustfa

                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