want to get value of cell 0 of selected rows in 2 text boxes
Your code does almost opposite. You are comparing cell value with textbox text and doing some operation.
You need to do something like:
for(i=0;i<=dataGridView1.Rows.Count-1;i++)
{
if (dataGridView1.Rows[i].Selected)
{
string str = dataGridView1.Rows[i].Cells[0].Value.ToString() + '-' + str;
}
}