In this article i am going to explain about how to fill the datatable using datareader and bind that datatable to gridview. Datareader is read only forward only way of reading data. Compare to dataset datareader is fast in terms of reading data. To fill the datatable using datareader DataTable.Load() methaod is used in that datareader object is passed as the argument. Create a new asp.net application and add a grid view in to display the details from the students table. Below is the html code used. Fill Datatable Using Data Reader For explanation purpose i have created a table called student and inserted some sample records. Below is the script used to create table and insert record into table. CREATE TABLE Students ( Id INT IDENTITY PRIMARY KEY, Name VARCHAR(100), Class TINYINT, Section CHAR(1), JoinedDate DATE ) GO INSERT INTO Students(Name,Class,Section,JoinedDate) VALUES('Student-1',10,'A','2009-06-01') INSERT INTO Students(Name,Class,...
Asp.Net,C#.Net,SQL Server Articles, Source Codes and Examples