Number of rows in DataGridView

1

I have a DataGridView and I need it to show me in a textbox the total number of rows I have in DataGridView.

How can I do this.

Below is 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;
        }
    
asked by anonymous 10.05.2017 / 18:20

1 answer

3

Using the RowCount of DataGridView .

Example:

textbox.Text = dgPedidoDiario.RowCount.ToString();

Link to Knowledge

    
10.05.2017 / 18:24