Can we use data reader to bind gridview?

Answer Posted / prasanth

data reader can be used to databind gri view

void Page_Load(Object sender, EventArgs e){ String Q; Sql
command cmd; Sql DataReader dr; SqlConnection conn = new
SqlConnection(); conn.ConnectionString =
ConfigurationManager.ConnectionStrings
["cn"].ConnectionString.ToString(); conn.Open
(); Q = "select * from tablename";
cmd= New Sqlcommand(Q, conn); dr =
cmd.ExecuteReader();
Gridview1.DataSource = dr; Gridview1.DataBind();}

Is This Answer Correct ?    17 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between web application and enterprise application?

542


In code behind class, name the type of code found. Is it the server side code or client side code?

774


Explain is the jit an interpreter?

561


What is 'Common Type System' (CTS) in .NET?

651


Please explain what is heap and what is stack?

567






What does stateless mean?

633


Is there any attempt system for microsoft technology papers?

1296


What is STA in .NET?

639


Explain what is a delegate?

582


Compare client server application with n-tier application

508


what are connection strings?

1744


How do you define the lease of the object in .net?

554


What is Code group in .Net with respect to CAS

1570


What is the need of OLE-automation?

633


What are virtual destructures?

531