//Get selected keywords and bind them with current selected file private void AddingKeywordsToFile(DataGridView dgv) { FilePersonKeywordClient client = new FilePersonKeywordClient(); Int32 selectedRowCount = dgv.Rows.GetRowCount(DataGridViewElementStates.Selected); //getting number of selected rows for (int i = 0; i < selectedRowCount; i++) { Console.WriteLine(dgv[1, dgv.SelectedRows[i].Index].Value.ToString()); client.InsertKeywordIntoFile(dgv[1, dgv.SelectedRows[i].Index].Value.ToString(), listBox_Files.SelectedItem.ToString()); } client.Close(); }