New to Telerik UI for WinForms? Download free 30-day trial

Binding to DataReader

To extract values from a data source using a DataReader, use the GridViewTemplate LoadFrom() method to consume an object instance that supports IDataReader. The code sample below uses a OleDbDataReader reading an Access data source:

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\DataSources\\Nwind.mdb");
conn.Open();
OleDbCommand cmd = new OleDbCommand("Select TOP 5 * FROM Customers", conn);
OleDbDataReader reader = cmd.ExecuteReader();
radGridView1.MasterTemplate.LoadFrom(reader);

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\DataSources\\Nwind.mdb")
conn.Open()
Dim cmd As New OleDbCommand("Select TOP 5 * FROM Customers", conn)
Dim reader As OleDbDataReader = cmd.ExecuteReader()
RadGridView1.MasterTemplate.LoadFrom(reader)

See Also

In this article