Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
i want to pass selected datagridview value to another datagridview in same page in C#.Net Windows Application.any one plz help me ......thanks in advance..
Posted 9-Nov-12 19:37pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
as biswarup told, do this in the cell click event of the grid view, when a particular cell is clicked then that event will be fired and, in code get that cell value, and add to the other grid
 
Thanks
Tapan kumar
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here is the code snippet
 
String ID;
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.RowIndex == -1))
            {
                 MessageBox.Show("");
            }
            else
            {
                try
                {
                    ID = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                }
                catch(Exception ex)
                {
                     MessageBox.Show("Error:" + ex.Message.ToString());
                }
             }
         }
Generate this cell click event and try this code; just update the cell value which cell value you want to pass.
 
Hope it helps.
  Permalink  
Comments
Member 9530923 at 17-Nov-12 1:36am
   
Thanks biswarup its good to see the solution...
biswarup88 at 17-Nov-12 1:37am
   
mark as answer if it works..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 645
1 OriginalGriff 560
2 CPallini 294
3 Peter Leow 185
4 RyanDev 146
0 OriginalGriff 6,034
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,129
3 Maciej Los 3,079
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100