Good afternoon. I need to pass data from the datagridview to the reportviwer to print, but as I am new to C # I am not able to pass the datatable to the reportview form, if someone can explain me a step by step I would appreciate it.
Follow my datagridview code
private void bln_gerar_Click(object sender, EventArgs e)
{
try
{
SqlCommand geracomissao = new SqlCommand("usp_RelatorioComissao", conexaoDADOSADV(true));
geracomissao.Parameters.AddWithValue("@VENDEDOR", this.txt_vendedor.Text);
geracomissao.Parameters.AddWithValue("@DTINICIAL", this.txt_dtinicial.Text);
geracomissao.Parameters.AddWithValue("@DTFINAL", this.txt_dtfinal.Text);
geracomissao.CommandType = CommandType.StoredProcedure;
geracomissao.ExecuteNonQuery();
SqlDataAdapter dados = new SqlDataAdapter(geracomissao);
DataTable dtLista = new DataTable();
dados.Fill(dtLista);
dgw_comissao.DataSource = dtLista;
dgw_comissao.Columns["NOTA"].ReadOnly = true;
dgw_comissao.Columns["CLIENTE"].ReadOnly = true;
dgw_comissao.Columns["PRODUTO"].ReadOnly = true;
dgw_comissao.Columns["VALOR PARCELA"].ReadOnly = true;
dgw_comissao.Columns["PARCELA S/ IMPOSTO"].ReadOnly = true;
dgw_comissao.Columns["VENCIMENTO"].ReadOnly = true;
dgw_comissao.Columns["PREÇO VENDA"].ReadOnly = true;
dgw_comissao.Columns["COMISSÃO VENDEDOR"].Visible = false;
}
catch
{
MessageBox.Show("Não exstem dados digitados para a consulta, por favor verificar!!!");
return;
}
}
The form code is where I'm putting reportview.
public partial class frmImpRelatorioComissao : Form
{
public frmImpRelatorioComissao()
{
InitializeComponent();
}
private void frmImpRelatorioComissao_Load(object sender, EventArgs e)
{
this.rpw_comissao.RefreshReport();
}
}