foreach (DataGridViewRow row in dataGridView1.Rows)
{currQty += row.Cells["dbbname"].Value;
}How to separate it with comma if data is more than 1 ?
example result:
db1,db2,db3
but if only one it will show
result:
db1
foreach (DataGridViewRow row in dataGridView1.Rows)
{currQty += row.Cells["dbbname"].Value;
}How to separate it with comma if data is more than 1 ?
example result:
db1,db2,db3
but if only one it will show
result:
db1
Know the answer? Post it. Somebody with the same question will find it here.


String currQty = "";
foreach (DataGridViewRow row in dataGridView1.Rows)
{
currQty = currQty + ',' + row.Cells["dbbname"].Value;
}
currQty = currQty.Substring(1,currQty.Length-2);
MessageBox.Show(currQty);
try this code you get excat output
i add following line because remove first and last ,
currQty = currQty.Substring(1,currQty.Length-2);
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Sep 5, 2022, 3:21 AM EDT