Load data GridControl DevExpress using a DataTable

1

I'm using Windows Forms , GridControl DevExpress , SQL Server 2008 .

I try to load a GridControl data using a DataTable . The code is as follows:

var dtDatos = GetAll("SELECT EmployeeID, FirstName, LastName, Address FROM Employees");
if (dtDatos.Rows.Count > 0)
{
    for (int Nro = 0; Nro < dtDatos.Rows.Count; Nro++)
    {
        ;
    }
}

The variable dtDatos is the DataTable that brings me the records from the database, and by for I try to fill it with data, but the problem is that I do not know what properties are use in a GridControl .

    
asked by Pedro Ávila 08.11.2016 в 00:03
source

3 answers

1

I do not see why doing the data assignment by hand, when you can directly link the GridControl to the data source using its property DataSource , for example:

gridControl1.DataSource = dtDatos 

For examples and tutorials, be sure to see the manual section Binding to Data .

    
answered by 08.11.2016 / 00:44
source
2

According to the following page, which is part of the DevExpress documentation, a GridControl has the following properties.

link

EditorContainer, IPrintableEx, IPrintable, IBasePrintable, IPrintHeaderFooter,
INavigatableControl, IToolTipControlClient, ISupportLookAndFeel, IDXManagerPopupMenu,
IViewController, IFilteredComponent, IFilteredComponentBase, IBoundControl,
ISupportXtraSerializer, IGestureClient, IGuideDescription,
IFilteredComponentColumnsClient, ISearchControlClient, IFilteredComponentColumns,
y ILogicalOwner'
    
answered by 08.11.2016 в 00:55
1

As long as your grid in the .aspx matches the data searched in BD (same names) .-

var dtDatos = GetAll("SELECT EmployeeID, FirstName, LastName, Address FROM Employees");

if (dtDatos.Count > 0)
{
  grilla.DataSource = dtDatos;
  grilla.DataBind();

}
    
answered by 14.12.2016 в 21:12