This is a migrated thread and some comments may be shown as answers.

Navigate through all the rows

3 Answers 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hugo
Top achievements
Rank 1
Hugo asked on 20 May 2011, 11:33 PM
Hi

I'm very new to the visual studio environment and telerik controls.  I'm using a Gridview with bound data and I need to navigate through all the data rows.  Basically I need to read the value of the second value to make a secuential process.

private void LlenarRestaurantes () {
           SqlDataReader dr ;
           SqlCommand cmd;
           string Sqlstring;
 
           Sqlstring = "   SELECT  '(' + rtrim(RE.sNumeroRestaurante) + ') ' +  RE.sNombreRestaurante  as RESTAURANTE,"
                       + "'\\'  +  rtrim (RE.sServidorDatos) + '\\Cambios\\' as [RUTA DE ENVIO] , 'SIN PROCESAR' as RESULTADO "
                       + " FROM         amRestaurantes AS RE INNER JOIN"
                       + " CambioRecetaRestaurante AS CR ON RE.sNumeroRestaurante = CR.sCodigoRestaurante"
                       + " WHERE     (CR.sConsecutivo = '" + lblNumeroDeCambio.Text  +  "')";
           cmd = new SqlCommand (Sqlstring , db);
           dr = cmd.ExecuteReader () ; 
           gvRestaurantes.DataSource = dr;
            
           gvRestaurantes.BestFitColumns();
       }


I know that it's a very simple task but as a novice I haven't found how to do it.  I'm using Windows 7 with Visual Studio 2010 Ultimate.

I need also  to write on the third column some custom values from me. I can do that?

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 21 May 2011, 05:03 PM
Hello Hugo,

You can just iterate trough all the rows and then get/set the value to a specific cell, something like this:
foreach (var row in radGridView.Rows)
{
    var valueFromSecondColumn = row.Cells[1].Value; // row.Cells["ColumnName"];
    //set value
    row.Cells[2].Value = someValue;
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Hugo
Top achievements
Rank 1
answered on 23 May 2011, 04:38 PM
Thanks for the quick response.

I'm having problems setting a value to a cell, I'm getting the error "The method specified is not compatible ".  The third column is generated from the query, I don't know if it affects. 


foreach (var fila in gvRestaurantes.Rows)
            {
                var Valor = fila.Cells[1].Value;
                fila.Cells[2].Value = "Procesado";//This intruction gives me an error
            }

Another question, Do you have a webpage where I can find explanations of all members of your components? There's the overview Webpage http://www.telerik.com/help/winforms/ribbonbar-overview.html but is not very deep for a novice as me.

Thanks 
0
Svett
Telerik team
answered on 25 May 2011, 04:24 PM
Hi Hugo,

I am not able to reproduce the issue with the supplied information. I would kindly ask you to share with us the data source and source code that you are using to initialize and bind the RadGridView instance. You can refer the API documentation here.

Please note that should open a new support ticket in order to be able to attache files.

Thank you for your cooperation. I am looking forward to your response.

Greetings,
Svett
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Hugo
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Hugo
Top achievements
Rank 1
Svett
Telerik team
Share this question
or