SQL data as to bring radgridview?...sorry I do not speak English

2 posts, 0 answers
  1. jorge
    jorge avatar
    1 posts
    Member since:
    Apr 2015

    Posted 29 Apr 2015 Link to this post

    I make a query to a database SQL attempt to bring the result to a radGridView .... I add the row but no data as it should?

    private void radButton1_Click(object sender, EventArgs e)
    MessageBox.Show("DEBE INGRESAR UN NRO DE ORDEN", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    if (txtNro.Text != "")
    SqlCommand consulta = new SqlCommand("select Convert(varchar(10),fecIni,103) as fecIni ,Convert(Varchar(10),fecFin,103) as fecFin from ordenes where nro_orden=@nro", conexion);
    consulta.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNro.Text));
    SqlDataReader registro = consulta.ExecuteReader();
    if (registro.Read())
    labelIni.Text = Convert.ToString(registro["fecIni"]);
    labelFinal.Text = Convert.ToString(registro["fecFin"]);
    MessageBox.Show("NO SE ENCONTRO EL NUMERO DE ORDEN INGRESADO", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    labelIni.Text = "";
    labelFinal.Text = "";
    DataTable dt = new DataTable();
    SqlCommand consulta2 = new SqlCommand("select medicamento,cantidad,programa,precioUnit,precioFin from DetalleOrden where nro_orden=@nro",conexion);
    consulta2.Parameters.AddWithValue("@nro", Convert.ToInt32(txtNro.Text));
    SqlDataAdapter da = new SqlDataAdapter(consulta2);
    rgv.DataSource = dt;


  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4166 posts

    Posted 04 May 2015 Link to this post

    Hello Jorge,

    Thank you for writing.

    Our Databinding RadGridView help article is quite useful regarding populating the grid with data. You just need to fill a DataTable and set it as RadGridView.DataSource. On the following links you can find helpful information about how to create a DataTable from a query:

    Please find attached a sample project as well.

    I hope this information helps. Should you have further questions, I would be glad to help.

    See What's Next in App Development. Register for TelerikNEXT.

Back to Top