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. Copy value from that table adapter to data grid cell, how?

Copy value from that table adapter to data grid cell, how?

Scheduled Pinned Locked Moved C#
questioncssdatabasehelptutorial
3 Posts 1 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.
  • T Offline
    T Offline
    TrooperIronMan
    wrote on last edited by
    #1

    What is best method to do this on Order Details data grid, when user select ProductID ProductPrice is automatically filled with value from Product table... and is on save written to Order details (so if price changed in Product table it will not be automatically updated in order details table (only when user select new product)? I already have idea, tried to do new table adapter that have parameter query that do just that, and have event celled edit call fill on new table adapter... only remaining problem is how to copy new value to existing tableadapter. I tried some work around things... but none is very professional so I'm looking for some elegant solution. So how to copy value from that table adapter to data grid cell if possible (I only managed to drag and drop new table adapter and create text box on form, so I copy value of text box to grid, not something I would like to do)?

    T 1 Reply Last reply
    0
    • T TrooperIronMan

      What is best method to do this on Order Details data grid, when user select ProductID ProductPrice is automatically filled with value from Product table... and is on save written to Order details (so if price changed in Product table it will not be automatically updated in order details table (only when user select new product)? I already have idea, tried to do new table adapter that have parameter query that do just that, and have event celled edit call fill on new table adapter... only remaining problem is how to copy new value to existing tableadapter. I tried some work around things... but none is very professional so I'm looking for some elegant solution. So how to copy value from that table adapter to data grid cell if possible (I only managed to drag and drop new table adapter and create text box on form, so I copy value of text box to grid, not something I would like to do)?

      T Offline
      T Offline
      TrooperIronMan
      wrote on last edited by
      #2

      OK this can give you some idea... private void order_DetailsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (order_DetailsDataGridView.Columns[e.ColumnIndex].DataPropertyName == "ProductID") {this.getProductCurrentPriceTableAdapter.Fill (this.northWndDataSet.GetProductCurrentPrice, (int)order_DetailsDataGridView[e.ColumnIndex, e.RowIndex].Value); order_DetailsDataGridView[e.ColumnIndex + 1, e.RowIndex].Value = decimal.Parse(unitPriceTextBox.Text); } } so instead last line I want something better, any idea?

      T 1 Reply Last reply
      0
      • T TrooperIronMan

        OK this can give you some idea... private void order_DetailsDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (order_DetailsDataGridView.Columns[e.ColumnIndex].DataPropertyName == "ProductID") {this.getProductCurrentPriceTableAdapter.Fill (this.northWndDataSet.GetProductCurrentPrice, (int)order_DetailsDataGridView[e.ColumnIndex, e.RowIndex].Value); order_DetailsDataGridView[e.ColumnIndex + 1, e.RowIndex].Value = decimal.Parse(unitPriceTextBox.Text); } } so instead last line I want something better, any idea?

        T Offline
        T Offline
        TrooperIronMan
        wrote on last edited by
        #3

        No one? Anyone please?

        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