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. General Programming
  3. Visual Basic
  4. how could I use the values of the dataGrid

how could I use the values of the dataGrid

Scheduled Pinned Locked Moved Visual Basic
csshelp
6 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.
  • C Offline
    C Offline
    costavo
    wrote on last edited by
    #1

    Hi all, How could I take the values of cells in the dataGrid and use them outside the dataGrid e.g: i have TimeIn & TimeOut for a certain person during one month (or more or less) i need to calculate the total hours ' in the specified time and view the total in a textBox syntax help (examples) is also needed thank you

    M R 2 Replies Last reply
    0
    • C costavo

      Hi all, How could I take the values of cells in the dataGrid and use them outside the dataGrid e.g: i have TimeIn & TimeOut for a certain person during one month (or more or less) i need to calculate the total hours ' in the specified time and view the total in a textBox syntax help (examples) is also needed thank you

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      There are really 2 choices here. You can grab the values out the datagrid, which means you would probably want to use the OnItemDataBound event and calculate the hours for each row as it is added or you can look at the datasource you are providing and get the values from there. For the OnItemDatabound event you can do a case statement like this (this is from memory so forgive me if it isnt exactly correct) - Select Case e.Item.Type Case Item 'Calculate from cell contents and get a TimeSpan object ts = Convert.ToDateTime(e.Item.Cells(#).Text).Subtract(Convert.ToDateTime(e.item.Cells(#).Text) txtTotalHours = ts.TotalHours End Select Something along those lines, I hope that helps! Cleako

      1 Reply Last reply
      0
      • C costavo

        Hi all, How could I take the values of cells in the dataGrid and use them outside the dataGrid e.g: i have TimeIn & TimeOut for a certain person during one month (or more or less) i need to calculate the total hours ' in the specified time and view the total in a textBox syntax help (examples) is also needed thank you

        R Offline
        R Offline
        Rahul Appu
        wrote on last edited by
        #3

        Hi, i will try to solve ur problem. The values u entered i mean the employee values that was stored in a table right, again if u want to retrive that values and display on data grid right, if yes means the values u stored in data grid while retriving then create a local variable that supports the perticular data type on which u are operating, with the index of the recordset suppose TimeIn t1 and TimeOut t2 then t2 - t1 for every loop of that perticular employee and keep adding the result to the local variable at last when the record set is empty then assign the value to the textbox out side the grid,I think u may confused but i did it, if u want more information abt this then mail to me :cool:

        C 2 Replies Last reply
        0
        • R Rahul Appu

          Hi, i will try to solve ur problem. The values u entered i mean the employee values that was stored in a table right, again if u want to retrive that values and display on data grid right, if yes means the values u stored in data grid while retriving then create a local variable that supports the perticular data type on which u are operating, with the index of the recordset suppose TimeIn t1 and TimeOut t2 then t2 - t1 for every loop of that perticular employee and keep adding the result to the local variable at last when the record set is empty then assign the value to the textbox out side the grid,I think u may confused but i did it, if u want more information abt this then mail to me :cool:

          C Offline
          C Offline
          costavo
          wrote on last edited by
          #4

          thak you both Rahul Appu & cleako srour_costavo@hotmail.com this is my email so if u have msn add me and we can discuss more online 10x a lot

          1 Reply Last reply
          0
          • R Rahul Appu

            Hi, i will try to solve ur problem. The values u entered i mean the employee values that was stored in a table right, again if u want to retrive that values and display on data grid right, if yes means the values u stored in data grid while retriving then create a local variable that supports the perticular data type on which u are operating, with the index of the recordset suppose TimeIn t1 and TimeOut t2 then t2 - t1 for every loop of that perticular employee and keep adding the result to the local variable at last when the record set is empty then assign the value to the textbox out side the grid,I think u may confused but i did it, if u want more information abt this then mail to me :cool:

            C Offline
            C Offline
            costavo
            wrote on last edited by
            #5

            how could I convert a value in the dataGrid to string in order to use it outside the grid?

            M 1 Reply Last reply
            0
            • C costavo

              how could I convert a value in the dataGrid to string in order to use it outside the grid?

              M Offline
              M Offline
              Marcus J Smith
              wrote on last edited by
              #6

              You either need to do something like OnItemDataBound because that will let you access each row or you will need to know the row index and cell number in order to access the .Text property which returns a string. I have found that many times though it will return a & nbsp; (spaced so it will show up) value so I almost always do a .Text.Replace("& nbsp;", "") on the value to make sure I dont have that HTML space. Check out http://www.datagridgirl.com/[^], there you will find many datagrid answers. Cleako

              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