DataGridView WinForms Control Powerful GridView C#.NET control supports data binding to various data sources GridView Data Binding to DataReader
When we are going to process the data binding, the GridView C#.NET component is able to extract values from a data source. This is achieved by applying a DataReader. The Kettic DataGridView Control is capable of data binding to a single level of data or multiple levels of hierarchical data. With the unbound mode support, the Kettic DataGridView can be bound to no data. The GridView C# API in the Control suite allows users to display the data in columns and rows at runtime. How to Bind GridView to DataReader in C#.NET
To use the DataReader to extract values from a data source when we are going to process the data binding, users of the GridView control is able to apply the GridViewTemplate LoadFrom() method to consume an object instance which is compatible with IDataReader. The C# code sample below demonstrates how to use an OleDbDataReader to recognize an Access data source for GridView C#.NET component.
C# code for applying a DataReader in Windows Forms application OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\KetticGridViewWinForms\\DataSamples "); conn.Open(); OleDbCommand cmd = new OleDbCommand("Select TOP 5 * FROM Dining Room", conn); OleDbDataReader reader = cmd.ExecuteReader(); ketticGridView1.MasterTemplate.LoadFrom(reader);
|