Number of lines in Datagridview

Asked

Viewed 849 times

1

I have a Datagridview and I need it to show me in a textbox the total number of lines that we have Datagridview.

how can I do this.

Below follows my code

private void ListaGrid()
    {
        string strSQL = @"SELECT
                          CONVERT(VARCHAR(10), CAST(SC.C5_EMISSAO AS DATE), 103) AS [EMISSÃO PED.],
                          SC.C5_NUM AS PEDIDO,
                          CONVERT(VARCHAR(10), CAST(SF.F2_EMISSAO AS DATE), 103) AS [EMISSÃO NF.],
                          SC.C5_NOTA AS NF,
                          SC.C5_XCLIDES AS CLIENTE,
                          SC.C5_VOLUME1 AS VOLUME,
                          S4.A4_NOME AS TRANSPORTADORA
                       FROM SC5020 AS SC
                       INNER JOIN SF2020 AS SF WITH (NOLOCK) ON SF.F2_DOC = SC.C5_NOTA
                       INNER JOIN SA4020 AS S4 WITH (NOLOCK) ON S4.A4_COD = SC.C5_TRANSP
                       WHERE SC.D_E_L_E_T_ <> '*' AND SC.C5_NOTA <> ''
                       AND SF.F2_EMISSAO BETWEEN CONVERT(datetime,'" + txtDtInicial.Text +"', 103) AND CONVERT(datetime,'"+ txtDtFinal.Text +"', 103) ORDER BY SF.F2_EMISSAO";

        //conexao = new SqlConnection(conm);
        comando = new SqlCommand(strSQL, conm);

        try
        {
            SqlDataAdapter dados = new SqlDataAdapter(comando);
            DataTable dtLista = new DataTable();
            dados.Fill(dtLista);

            dgPedidoDiario.DataSource = dtLista;
        }

1 answer

3


  • I can give you an improved answer?

  • Sure you can, it’s always good

  • Thanks. I didn’t do anything, I just explained the property and adapted the code =D

  • It’s much better this way :)

  • Gave right here thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.