foreach (GridViewRow row in GridView1.Rows)
{
var chk = row.FindControl("myCheckBox") as CheckBox;
if (chk.Checked)
{
var email = row.FindControl("LabelEmail") as Label;
txtEmails.Text += (string.Join(",", email.Text));
}
I’m extracting the email from the grid view and suppose to put the email accordingly with a comma separating them. I tried using the string.join method however it’s not appearing in the textbox at all. I tried not using string.join but the comma will be added beside every email. How do I separate the email properly?
Example : Helloworld@gmail.com, Helloeveryone@gmail.com, HelloBye@gmail.com
Instead of:
Try this:
Edit:
Because it adds a comma to the the last email, you can do something like this to prevent that:
Hope this helps!