copy selected rows from one gridview to another gridview


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: copy selected rows from one gridview to another gridview

  1. #1
    Join Date
    Mar 2007
    Posts
    4

    copy selected rows from one gridview to another gridview

    Hi

    i have 2 gridviews say gridview1 and gridview2. I am populating gridview1 with data from database and on selection of the row from gridview1 i am getting productid from gridview1 and passing it as a control to gridview2 so that the row can be populated in gridview2 by using that productid.

    Now my problem is it works fine with the one row selection. If i select another row than it overwrites the first one. which i dont want i want whenever user selects the row it should keep on adding in the gridview2.

    Any help is appreciated.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What kind of data source are you using for gridview2? I would use a collection or dataset; when you select a row from gridview1, add the selected item to the data source for gridview2, then re-bind.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Mar 2007
    Posts
    4
    i am using a dataset. I am just passing a unique id (productid) to gridview2 and using that id will populate row in gridview2. But when next time any other row is selected in gridview1 the row in gridview2 is overwritten with new one.

    Can you show me how.

    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't understand what you mean by "passing a unique id to gridview2"? A gridview is a control, not a method, so how do you pass a value to it?

    You can find several examples on the Web of adding a row to a dataset: http://www.google.com/search?q=how+to+add+row+dataset
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Mar 2007
    Posts
    4
    I mean once user selects row in gridview1, i will get the value of field productid and use that value in gridview2.

    I have created a tableadapter with method as GetDataByProductID(Int32 productid) and my parameter source is control and controlID is GridView1.

    I hope i have cleared some doubts.

  6. #6
    Join Date
    Feb 2010
    Posts
    1

    Copy and add selected row data from gridview1 to gridview2

    Hi Zubinkasad:
    I am working on the identical code.
    I have gridview1 which is populated from a datatable using sqlconnection string. I do not know how to bind it to gridview2 so that only selected row(s) added to gridview2 using selectedindexchange. And for subsquent selectedindexchange it should add the row data (not overwrite)
    I understand you have worked on this code. I will appriciare if you can provide example of you code.
    Thanks a lot.

Similar Threads

  1. Replies: 0
    Last Post: 03-12-2007, 07:58 AM
  2. Replies: 0
    Last Post: 02-15-2006, 09:14 AM
  3. Replies: 0
    Last Post: 10-11-2005, 09:13 AM
  4. Replies: 2
    Last Post: 05-03-2002, 06:16 AM
  5. Replies: 0
    Last Post: 03-14-2001, 03:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center