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. SOS

SOS

Scheduled Pinned Locked Moved ASP.NET
helpannouncement
3 Posts 2 Posters 1 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.
  • M Offline
    M Offline
    mostafa_h
    wrote on last edited by
    #1

    HI ! i wrote the following code fo add and save : private void btnadd_Click(object sender, System.EventArgs e) { txtname.Text=""; txtfname.Text="" } and for save : private void btnsave_Click(object sender, System.EventArgs e) { DataRow newrow=dt.NewRow(); newrow["name"]=txtname.Text; newrow["fname"]=txtfname.Text; dt.Rows.Add(newrow); da.Update(dt); int RowTablePosition=0; RowTablePosition =dt.Rows.Count-1; } but whenever i save , ONLY THE FIRST RECORD OF TABLE IS ADDED !! thanks for any help ! yours ! mostafa hosseiny b.

    G 1 Reply Last reply
    0
    • M mostafa_h

      HI ! i wrote the following code fo add and save : private void btnadd_Click(object sender, System.EventArgs e) { txtname.Text=""; txtfname.Text="" } and for save : private void btnsave_Click(object sender, System.EventArgs e) { DataRow newrow=dt.NewRow(); newrow["name"]=txtname.Text; newrow["fname"]=txtfname.Text; dt.Rows.Add(newrow); da.Update(dt); int RowTablePosition=0; RowTablePosition =dt.Rows.Count-1; } but whenever i save , ONLY THE FIRST RECORD OF TABLE IS ADDED !! thanks for any help ! yours ! mostafa hosseiny b.

      G Offline
      G Offline
      god_bless_the_world
      wrote on last edited by
      #2

      I think you should accept the changes after updating for the change to be committed. Add 'dt.AcceptChanges();' statement after 'da.update(dt);' statement. Hope this solves your problem In faith there is enough light for those who want to believe and enough shadows to blind those who don't. - Blaise Pascal

      M 1 Reply Last reply
      0
      • G god_bless_the_world

        I think you should accept the changes after updating for the change to be committed. Add 'dt.AcceptChanges();' statement after 'da.update(dt);' statement. Hope this solves your problem In faith there is enough light for those who want to believe and enough shadows to blind those who don't. - Blaise Pascal

        M Offline
        M Offline
        mostafa_h
        wrote on last edited by
        #3

        hi there !

        god_bless_the_world wrote:

        Add 'dt.AcceptChanges();' statement after 'da.update(dt);' statement.

        But i get no result . is there any guide ! mostafa hosseiny b.

        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