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. Web Development
  3. Update Datagrid problem

Update Datagrid problem

Scheduled Pinned Locked Moved Web Development
helpquestionannouncement
4 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.
  • S Offline
    S Offline
    Steve Severance
    wrote on last edited by
    #1

    When I try to update my databae using the update on the datagrid the original values, not the modified ones are passed. Any ideas? Thanks.(No, the function in its current state does not function) public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int)e.Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...

    N 1 Reply Last reply
    0
    • S Steve Severance

      When I try to update my databae using the update on the datagrid the original values, not the modified ones are passed. Any ideas? Thanks.(No, the function in its current state does not function) public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int)e.Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      I'm assuming TextBox Contact, etc. contain the updated values and UpdateVendor is your SqlCommand. Where are you assigning the contact, address, phone and fax to SqlCommand parameters?

      S 1 Reply Last reply
      0
      • N Not Active

        I'm assuming TextBox Contact, etc. contain the updated values and UpdateVendor is your SqlCommand. Where are you assigning the contact, address, phone and fax to SqlCommand parameters?

        S Offline
        S Offline
        Steve Severance
        wrote on last edited by
        #3

        here is the exact code. public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int).Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.Parameters[1].Value = Contact.Text; UpdateVendor.Parameters[2].Value = Address.Text; UpdateVendor.Parameters[3].Value = Phone.Text; UpdateVendor.Parameters[4].Value = Fax.Text; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...

        N 1 Reply Last reply
        0
        • S Steve Severance

          here is the exact code. public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int).Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.Parameters[1].Value = Contact.Text; UpdateVendor.Parameters[2].Value = Address.Text; UpdateVendor.Parameters[3].Value = Phone.Text; UpdateVendor.Parameters[4].Value = Fax.Text; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Using DataGrid Look at the Checkboxes and TextBoxes section.

          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