Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a gridview in which data are comes from the database. Now i want to update that data when update link clicked and selected row's data should go to in textbox and when update button click the updated data should store to database.
Posted

 
Share this answer
 
try this...

1.select click event of datagridview
2.find row index like...
C#
int row = dgvReleaseOrder.CurrentCell.RowIndex;

3.using for loop
C#
for (int row = 0; row < dgvReleaseOrder.Rows.Count - 1; row++)
                {
                    txt1.text = dgvReleaseOrder.Rows[row].Cells[1].Value.ToString();
                    txt2.text = dgvReleaseOrder.Rows[row].Cells[2].Value.ToString();
                    txt3.text = dgvReleaseOrder.Rows[row].Cells[3].Value.ToString();
                    txt4.text = dgvReleaseOrder.Rows[row].Cells[4].Value.ToString();
                    txt5.text= dgvReleaseOrder.Rows[row].Cells[5].Value.ToString();
                    txt6.text = dgvReleaseOrder.Rows[row].Cells[6].Value.ToString();
                    txt7.text= dgvReleaseOrder.Rows[row].Cells[7].Value.ToString();
                    txt8.text = dgvReleaseOrder.Rows[row].Cells[8].Value.ToString();
                    txt9.text= dgvReleaseOrder.Rows[row].Cells[9].Value.ToString();
                    txt10.text= dgvReleaseOrder.Rows[row].Cells[10].Value.ToString();
}


happy coding
 
Share this answer
 
Comments
JR009 16-Dec-13 1:35am    
Thank you very much Joy Anand Raj for your useful answer.
An@nd Rajan10 16-Dec-13 1:40am    
If it helps you to solve, please do accept it as solution it may be helpful to others...

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