ユーザー名とチェックボックスを使用して、DB テーブルの行を一覧表示するページがあります。CheckBox.checked が true のときにユーザーにメールを送信する機能が必要ですが、ページにメールが表示されません。私はこれらの方法を持っています:
public class ListRequest
{
public string UserName { get; set; }
public string Email { get; set; }
}
public List<ListRequest> PreencheValores(SqlDataReader reader)
{
var lista = new List<ListRequest>();
while (reader.Read())
{
var listRequest = new ListRequest();
listRequest.UserName = reader["User"].ToString();
listRequest.Email = reader["Email"].ToString();
lista.Add(listRequest);
}
return lista;
}
public List<ListRequest> ConsultarRequest()
{
var lstRetorno = new List<ListRequest>();
using (objConexao = new SqlConnection(strStringConexao))
{
using (objCommand = new SqlCommand(strSelectPorID, objConexao))
{
try
{
objConexao.Open();
objCommand.Parameters.AddWithValue("@UserName", dm3);
var objDataReader = objCommand.ExecuteReader();
if (objDataReader.HasRows)
lstRetorno = PreencheValores(objDataReader);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
objConexao.Close();
}
}
}
return lstRetorno;
}
どうすればこのために foreach を作成できますか?? このリストにすべての文字列 Email を取得する必要がありますが、私のページに Email が表示されません。CheckBox.cheked が true の場合、foreach (GridView.Rows の GridViewRow 行) を使用して名前を取得します。問題は明確ですか?わかりました!