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

Define atomicity?

798


What is ado control?

708


How to maintain the relation between two tables in ADO.NET?

760


What are the rules to implement connection pooling?

750


Command objects uses, purposes and their methods.

725


How to read data with the sqldatareader ?

741


Explain the DataAdapter.Update() and DataSetAcceptChanges() methods.

746


What is ado or jdbc?

704


What are the advantages and disadvantages of using datalist?

719


How can we serialize the dataset object?

745


How to retrieve the user id which is provided while windows authentication?

812


What are the different layers of ado.net?

753


What is the difference between data grid and data repeater?

754


Explain the architecture of ado.net?

807


Do we use stored procedure in ADO.Net?

748