Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Here is the code snippet

C#
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.
 
Share this answer
 
Comments
Member 9530923 17-Nov-12 1:36am    
Thanks biswarup its good to see the solution...
sahabiswarup 17-Nov-12 1:37am    
mark as answer if it works..
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900