The only way I could see your code not working is if you had no rows in your DataGridView
, so there was nothing to iterate over. Even if you had several rows and they all had empty names, you'd at least get a string with several commas in it.
Also, here's a slightly shorter way to get your list of names, using LINQ:
var allNames = string.Join(",",
DGVDekripsi.Rows.Cast<DataRow>().Select(x => x.Field<string>(0)));