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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.


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);
Rajanikant HawaldarPosted Sep 5, 2022, 7:21 AM