I'm having problems displaying a gridview, it's not displaying the right data, it looks like it's trying to display vertically, I've already changed the Gridline property to horizontal, both and now this Name, same as another gridView I've been running. This my gridview is being populated with information coming from the database. My gridView is this:
<asp:GridView ID="gridacao" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" ForeColor="#333333" GridLines="None" ToolTip="Valores Atualizados das ações" Width="344px">
<AlternatingRowStyle BackColor="Gainsboro" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
in part .cs is like this:
public partial class ExibeAcao : System.Web.UI.Page
{
string cd;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
exibirAcao();
}
}
catch (Exception ce1)
{
throw new Exception(ce1.Message.ToString());
}
}
private void exibirAcao()
{
try
{
cd = "PETR4";
Trataformes tf = new Trataformes();
this.gridacao = tf.mostraAcao(cd, ref gridacao);
}
catch (Exception e2)
{
throw new Exception(e2.Message.ToString());
}
}
protected void gridacao_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
The show () method is this:
public GridView mostraAcao(string cd, ref GridView gv)
{
try
{
ManipulaBanco mp = new ManipulaBanco();
return mp.exibeAcao(cd, ref gv);
}
catch (Exception e)
{
throw new Exception(e.Message.ToString());
}
}
and the method pulls out of the database is this:
public GridView exibeAcao(string cod, ref GridView tb)
{
try
{
bancotccEntities bc = new bancotccEntities();
var pa = from ac in bc.acao
where ac.codigo == cod
select new
{
Ação = ac.codigo,
Empresa = ac.empresa,
Tipo = ac.tipo,
Data = ac.data,
Hora = ac.hora,
Abertura = ac.abertura,
Maxima = ac.maxima,
Minima = ac.minima,
Média = ac.medio,
Valor = ac.fechamento,
fechamento_Ontem = ac.f_anterior,
Volume_de_Ações = ac.volume,
Valor_Negociado = ac.v_financeiro,
Variação = ac.variacao,
Fase = ac.fase
};
tb.DataSource = pa.ToString();
tb.DataBind();
return tb;
}
catch (Exception e)
{
throw new Exception(e.Message.ToString());
}
}
I'm getting the result below:
I would like it to appear horizontally, does anyone know how?