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. Database & SysAdmin
  3. Database
  4. How to edit Dataset value (NOT DATA GRID)

How to edit Dataset value (NOT DATA GRID)

Scheduled Pinned Locked Moved Database
questioncsswpfwcftutorial
4 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.
  • S Offline
    S Offline
    sacr83
    wrote on last edited by
    #1

    Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....

    CheeN

    K A 2 Replies Last reply
    0
    • S sacr83

      Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....

      CheeN

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      A DataSet object is a collection of DataTable objects. You could loop through the table and update the age with something like this: For Each row As DataRow In ds.Tables(0).Rows row("age") = row("age") / 2 Next Or you could just do it in the select by changing your select statement to this string: "select name, address, age/2 as age" Hope this helps.

      S 1 Reply Last reply
      0
      • S sacr83

        Hi All, i want to edit DataSet value before binding to GridView. How can i do that..? conn.open(); string result="select name,address,age"; sqlCommand cmnd=new sqlCommand(result); sqlDataAdapter ad=new sqlDataAdapter(result,conn); DataSet ds=new DataSet(); result.Connection=conn; ad.SelectCommand=result; // in here i want to edit (divide age value by 2) before bind data to gridview. ad.fill(ds); GridView1.DataSource=ds; GridView1.DataBind(); conn.close(); i want to divide age value by 2 before bind data to gridview.How can i do that...??? Thank you very much .....

        CheeN

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

        For Each dr As DataRow In ds.Tables(0).Rows

        dr("ColumnName") = (dr("ColumnName") / 2)

        Next

        Where ColumnName is your data column in the DataSet Table.

        I don't speak Idiot - please talk slowly and clearly I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury Driven to the arms of Heineken by the wife

        1 Reply Last reply
        0
        • K Kschuler

          A DataSet object is a collection of DataTable objects. You could loop through the table and update the age with something like this: For Each row As DataRow In ds.Tables(0).Rows row("age") = row("age") / 2 Next Or you could just do it in the select by changing your select statement to this string: "select name, address, age/2 as age" Hope this helps.

          S Offline
          S Offline
          sacr83
          wrote on last edited by
          #4

          Thank u 4 your post. I fixed my problem..Thank u all...

          CheeN

          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