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. C#
  4. How to edit Dataset value (NOT DATA GRID)

How to edit Dataset value (NOT DATA GRID)

Scheduled Pinned Locked Moved C#
questioncsswpfwcftutorial
8 Posts 4 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 F V 3 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
      kstls
      wrote on last edited by
      #2

      would it be ok to do it with you sql statement. In that case you could do: Select name, adress, age / 2 as age from [yourdbname]

      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

        F Offline
        F Offline
        Fired Fish Gmail
        wrote on last edited by
        #3

        You can create new coloum that age value is divied by 2, and delete the old age column and set the new column's name to "age"

        S 1 Reply Last reply
        0
        • K kstls

          would it be ok to do it with you sql statement. In that case you could do: Select name, adress, age / 2 as age from [yourdbname]

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

          Thank you for you reply .....But i had a problem when i going to DataBind. this is the error.. GridView1.DataBind(); //------ error - A field or property with the name 'age' was not found on the selected data. But i correctly configured on GridView1.I use a BoundField to view this 'age' with DataField='age'on my GridView1 control.. Why i got this error..????

          CheeN

          S 1 Reply Last reply
          0
          • S sacr83

            Thank you for you reply .....But i had a problem when i going to DataBind. this is the error.. GridView1.DataBind(); //------ error - A field or property with the name 'age' was not found on the selected data. But i correctly configured on GridView1.I use a BoundField to view this 'age' with DataField='age'on my GridView1 control.. Why i got this error..????

            CheeN

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

            hey i fixed that prob...thank you bude rly thank......

            CheeN

            K 1 Reply Last reply
            0
            • F Fired Fish Gmail

              You can create new coloum that age value is divied by 2, and delete the old age column and set the new column's name to "age"

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

              Thank you friend..i fixed that problem.using follwing codes string result="select name,address,age/2 as nAge"; On my GridView1 I set my DataField ='nAgew' Then its all right... Thank you all of you to Guide me to fixed that problem....

              CheeN

              1 Reply Last reply
              0
              • S sacr83

                hey i fixed that prob...thank you bude rly thank......

                CheeN

                K Offline
                K Offline
                kstls
                wrote on last edited by
                #7

                My pleasure. Glad i could help

                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

                  V Offline
                  V Offline
                  vinodkrebc
                  wrote on last edited by
                  #8

                  You can change it very easily suppose you have the dataset ds Then ds.Tables[0].rows[2].columns[2]="Your New Value"; Thank you

                  Vinod Kumar Prajapati Software Engineer EBC Publishing Pvt. Ltd.

                  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