Can a DataReader be used as a DataSource for a GridView.
If it is so how will you handle paging.

Answer Posted / karthikeyant

some changes made in the above code

cmd.Connection = CON; //_cmd is sqlCommand and
CON is Connection
_cmd.CommandText = "select
Book_Code,ISBN,Title_Of_book from Book_Master";

SqlDataReader dr = _cmd.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(dr);
dr.Close();
_cmd.Dispose();

dataGridView2.DataSource = dataTable;

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you merge 2 datasets into the third dataset in a simple manner?

784


What is dataadapter in ado.net?

714


Which property is used to check whether a DataReader is closed or opened?

819


What is a datagridview?

753


What are the benefits of ADO.NET?

871


What is variable view?

684


What is the executescalar method?

800


Which ado.net object is very fast in getting data from the database?

877


The answers which posted above is not satisfied my requirement? Can some one post teh exact answer? Thanx

1816


Define the executescalar method?

697


What are the data access namespaces in .NET?

911


What is the difference between DataReader and DataSet in ADO.NET?

847


How can we load multiple tables in to dataset?

816


What are the difference between readonly vs. Const?

722


What is bubbled event can you please explain?

753