Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to select a row by clicking(mouse) a row and thae data will show in some textbox. :(( plz help.
plz give details..
Posted

Supposing the name of the datagridview is dgvGrid and Textbox name is txtName now:-

on click event of datagridview add the following code:-


C#
if (dgvGrid.Rows.Count > 0 &  dgvGrid.CurrentRow.Index>=0)
           {
              
               if (dgvGrid.Rows[dgvGrid.CurrentRow.Index].Cells[dgvGrid.CurrentCell.ColumnIndex].Value != null)
               {
                   txtName.Text = dgvGrid.Rows[dgvGrid.CurrentRow.Index].Cells[dgvGrid.CurrentCell.ColumnIndex].Value.ToString();
               }
           }
 
Share this answer
 
GridView is rendered as a table to the browser.
You can use Select CommandField to select the row.
Handle the GridView1_RowCommand event to access the selected values.

Hope it helps.
 
Share this answer
 
Please inform me if it helps you or let me know what are you exactly looking for.
 
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