すべての企業にコンテンツをメールで送信する編集可能な GridView があります。Gridview の最初の行には、会社名が含まれています (1 行に 1 つの名前のみ)。最初の行の会社名に基づいて、特定の電子メール アドレスに Gridview を電子メールで送信したいと考えています。例 - 最初の行が companyname1 と等しい場合、電子メールを会社 1 に送信します。最初の行が会社 2 に等しい場合、メールを会社 2 に送信します。私は次のことを試みました:
//C# - ボタンの背後にあるコード スニペット
foreach (GridView item in gvCompanies.Rows)
{
if (item.SelectedRow.Cells[1].Text == "company1")
{
txtEmailAddresses.Text = "company1@gmail.com";
}
else if (item.SelectedRow.Cells[1].Text == "company2")
{
txtEmailAddresses.Text = "company2.com";
}
else if (item.SelectedRow.Cells[1].Text == "company3")
{
txtEmailAddresses.Text = "company3@aol.com";
}
else if (item.SelectedRow.Cells[1].Text == "company4")
{
txtEmailAddresses.Text = "company@aol.com";
}
}
...ここで何が間違っているかについて、誰かがガイダンスを提供できますか?