Click here to Skip to main content
12,292,669 members (65,116 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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 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 17-Nov-12 1:36am
   
Thanks biswarup its good to see the solution...
biswarup88 17-Nov-12 1:37am
   
mark as answer if it works..
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  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160518.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2016
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