Good morning. You see, I'm doing a project that includes a profile, and that profile has the option of adding an image. The issue here is that it saves the path of the image in BD and the image in the folder. But when creating a new user, the Image control is null. How can I make this image by default when creating a new user?
This is the method to consult BD image:
protected void ConsultarImagen()
{
SqlConnection conexion = new SqlConnection(cadena);
SqlCommand com = new SqlCommand();
string id = Session["IdUsuario"].ToString();
lblId.Text = id;
com.CommandText = "Select ruta_imagen from tb_c_usuarios where id=" + id;
com.CommandType = CommandType.Text;
com.Connection = conexion;
conexion.Open();
var dataReader = com.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(dataReader);
if(dataTable!= null && dataTable.Rows.Count > 0)
{
string PathImagen = dataTable.Rows[0]["ruta_imagen"].ToString();
string URLPath = "http://" + Request.Url.Authority + "/" + PathImagen;
imagenPerfil.ImageUrl = URLPath;
}
conexion.Close();
imagenPerfil.DataBind();
}