Good afternoon, folks. I have a question when setting up a gridview I do not have a lot of knowledge in C # I did it that way
string sql = "SELECT pr.codigo_chave,pr.codigo_produto,pr.nome_produto,ca.nome_categoria FROM infobook_net.produtos pr inner join categorias ca on pr.codigo_categoria = ca.codigo_categoria";
Response.Write(sql);
cmd.CommandText = sql;
cmd.Connection = sqlConnection1;
try
{
sqlConnection1.Open();
MySqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
GridView1.DataSource = reader;
GridView1.DataBind();
}
}
else
{
Response.Write("não foram encontrados dados");
}
}
catch (Exception ex)
{
Response.Write(Convert.ToString(ex));
}
It is running and filling the gridview only when it has more than one return line when only one has it it does not mount anything and does not show anything does anyone have an idea how to do it?
Thank you