Click here to Skip to main content
16,021,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I made a selectable datagrid. But then, I can't get datas from the selected row and save it into a variable. The data in MySQL includes name, date and address; what I need is to save that 3 data into 3 variables also. Any idea on how to do this? Thank you.
Posted

1 solution

C#
if(DataGridView1.SelectedRows.Count <>0)
{
   DataGridRow row= DataGridView1.SelectedRows(0);
   Name = row.Cells(row.cells["Name"].value;
   Date = row.Cells(row.cells["Date"].value;
   Address = row.Cells(row.cells["Address"].value;
}
 
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