Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / rahul singhal

yes u can use data reader to fill gridview with while
function. and paging depends upon the datagrid property. if
u use custom paging there in no possibility with data
reader. u will have to use data table to fill data grid and
data table should be filled through data reader.

Is This Answer Correct ?    9 Yes 1 No

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

Answer / 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

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

Answer / dinesh sharma

_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();
dts.Columns.Add("Book_Code");
dts.Columns.Add("ISBN");
dts.Columns.Add("Title_Of_book"); DataRow drs;
while (dr.Read())
{
drs = dts.NewRow();
drs[0] = dr[0].ToString();
drs[1] = dr[1].ToString();
drs[2] = dr[2].ToString();
dts.Rows.Add(drs);

Application.DoEvents();




}
dataGridView2.DataSource = dts;


dr.Close();
_cmd.Dispose();

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More ADO.NET Interview Questions

How to pass values into a datatable?

0 Answers  


How to add Primary key in DataSet

6 Answers  


How to create dynamic gridview?

0 Answers   MCN Solutions,


What are ado.net objects?

0 Answers  


Whate are different types of Commands available with DataAdapter ?

2 Answers  


Which method in OLEDBAdapter is used to populate dataset with records?

0 Answers  


Is it possible to load multiple tables in a Dataset?

0 Answers  


Explain how to call the sql commands asynchronously in ado.net version 2.0?

0 Answers  


Which database is the ado.net sql connection object designed for?

0 Answers  


Explain the role of data provider in ado.net?

0 Answers  


What is a column variable?

0 Answers  


Can we create Synonymns in MS Acess,My Sql Server,Sql Server? But iam we can create in oracle!

0 Answers  


Categories