Click here to Skip to main content
14,971,029 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i click the edit button in grid view i need the corresponding record values to be displayed in the text boxes and drop down lists in order to update their values. what is the code for doing so. Right now i am editing it directly on grid vie. i need to edit the values in their text boxes and pdatethem ..how can i achieve this,..pls help me friends.

pls help me frnz
Posted
Comments
Kenneth Haugland 25-Jul-12 12:43pm
   
WinForms or WPF?
ajithk444 25-Jul-12 12:47pm
   
windows form
Raje_ 25-Jul-12 12:48pm
   
Where is your textbox in gridview, on same page or on different page?
ajithk444 25-Jul-12 12:57pm
   
on same page only.
ajithk444 25-Jul-12 12:59pm
   
i have 8fields.five text boxes and three dropdown lists.when i click on edit button in grid view i want all the 8 fields to be filled with the values in them.!any help friends..?
Raje_ 25-Jul-12 13:05pm
   
Go to this link:-
http://www.codeproject.com/Questions/264780/DataGridView-selected-rows-column-values-to-textbo

1 solution

On DataGridView.SelectionChanged Event
Write the following code:-
C#
private void DataGridView1_SelectionChanged(object sender, EventArgs e)
{
  if( DataGridView1.SelectedRows.Count = 0 )
  {
    TextBox1.Value = DataGridView1.SelectedRows(0).Cells(0).Value;
    TextBox2.Value = DataGridView1.SelectedRows(0).Cells(1).Value;
    //your code
  }
}


Make sure that SelectionMode Property of DataGridView is set to FullRowSelect for this to work.
   

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