我有一个页面,其中列出了我的DB表中的行,以及用户名和CheckBox。我需要一个功能,发送电子邮件给用户时,CheckBox.checked是真的,但不显示电子邮件在我的页面。我有这些方法:
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;
}我怎么才能做到这一点??我需要得到所有字符串电子邮件到这个列表,但不显示电子邮件在我的页面。现在,当CheckBox.cheked为真时,我使用foreach (GridView.Rows中的GridViewRow行)来获取名称。我说得够清楚了吗?谢谢!
发布于 2013-07-10 22:18:07
如果要对objDataReader中的每一行执行某些操作,请使用
While objDataReader.Read()
'do something
End Whilehttps://stackoverflow.com/questions/17572345
复制相似问题