Inquiridor
GridView, me ajudeeem x_x

Pergunta
-
galera eu estou querendo gerar relatórios de várias categorias, secretaria, aluno, diretoria, disciplinário e professores.
e queria mostrar meus dados em um gridview, tem como vcs me ajudarem?
tudo que já fiz foi:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnProf_Click(object sender, EventArgs e)
{
string RelatProf = "SELECT INTO PROFESSOR (NomeProf, RGProf);";
}
protected void btnAlu_Click(object sender, EventArgs e)
{
string RelatAlu = "SELECT INTO ALUNO (NomeAluno, TurmaAluno);";
}
protected void btnDir_Click(object sender, EventArgs e)
{
string RelatDir = "SELECT INTO DIRETORIA (NomeDir, RGDir);";
}
protected void btnSec_Click(object sender, EventArgs e)
{
string RelatSec = "SELECT INTO SECRETARIA (NomeSec, RGSec);";
}
protected void btnDisc_Click(object sender, EventArgs e)
{
string RelatDisc = "SELECT INTO DISCIPLINARIO (NomeDisc, RGDisc);";
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
if ()
{
() ;
}
SQLDSCadas.SelectedCommand = SelectedCadas;
SQLDSCadas.Selected();
}
}
a parte em destaque é a qual nao estou sabendo fazer
agradeço desde já;
Todas as Respostas
-
-
void geraRelatorio() { string sql; MeuRelatorio.Visible=True; if (Relatorios.SelectedItem.Value == "Aluno") { sql = // query relatorio aluno; } else if (Relatorios.SelectedItem.Value == "Professor") { sql = // query relatorio professor; } else if (Relatorios.SelectedItem.Value == "Diretoria") { sql = // query relatorio Diretoria; } else if (Relatorios.SelectedItem.Value == "Secretaria") { sql = // query relatorio Secretaria; } else { sql = // query relatorio Disciplinario; } String DefineConexao = "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" + Server.MapPath("App_Data/Banco.mdb"); OleDbConnection MinhaConexao = new OleDbConnection(DefineConexao); OleDbCommand ComandoSQL = new OleDbCommand(); ComandoSQL.Connection = MinhaConexao; ComandoSQL.CommandType = CommandType.Text; OleDbDataAdapter MeuComando = new OleDbDataAdapter(); MeuComando.SelectCommand = ComandoSQL; DataSet ds = new DataSet(); ComandoSQL.CommandText = sql; MeuComando.Fill(ds, "tabela"); DataView tabela = new DataView(ds.Tables[0]); MeuRelatorio.DataSource = tabela; MeuRelatorio.DataBind();
Esse é o Berind c# .... Fiz com DataGrid e com um banco em access
<asp:DropDownList ID="Relatorios" runat="server" Width="200px"> <asp:ListItem Selected="True" id="Professor" Value="Professor"> Professor </asp:ListItem > <asp:ListItem id="Aluno" Value="Aluno"> Aluno </asp:ListItem > <asp:ListItem id="Diretoria" Value="Diretoria"> Diretoria </asp:ListItem > <asp:ListItem id="Secretaria" Value="Secretaria"> Secretaria </asp:ListItem > <asp:ListItem id="Disciplinario" Value="Disciplinario"> Disciplinario </asp:ListItem > </asp:DropDownList> <asp:Button ID="btRelatorio" runat="server" Text="gerar Relatorio" OnClick="geraRelatorio" />
<asp:DataGrid ID="MeuRelatorio" runat="server" Width="930" CellPadding="3" Visible="False" />
Esse é o aspx. Eu fiz o seguinte, coloqueo um DropList para vc escolher qual relatorio vc quer, com isso gera uma sql para ele e monta o Datagrid. Vc so terá que colocar a query para os relatorios de cada um.
Espero ter ajudado, qualquer coisa posta aqui.
- Editado Gustavo Brum sexta-feira, 1 de outubro de 2010 18:51 Erro