Can we use data reader to bind gridview?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / swathi
this is also same as the Dataset.
these are steps:
1. SqlConnection con=new SqlConnection(ConnectionString);
2. SqlCommand com=new SqlCommand("Select * from
TableNAme",con);
3. SqlDataReader dr;
4. con.open();
5. dr=com.ExecuteReader();
6. Datagrid1.DataSource=dr;
7. DataGrid1.DataBind();
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / minhaj
yes, we can bind
but datagrid can
not be backword
because DR is
forward only
| Is This Answer Correct ? | 2 Yes | 0 No |
When we go for html server controls and when we go for web server controls?
What is connected and diconnected database ?
What is the difference between function and stored procedure?
What property do you have to set to tell the grid which page to go to when using the Pager object?
What is file extension of Webservices in .Net?
What does SCM do?
What is the use of common language runtime?
What is the reason of occurring overflow-underflow arithmetic exception error, it shows error message when we run our program by adding control?
What is an Interface? Have you ever developed an Interface.
Which namespace does it belong to by default?
What are the properties of ADO.NET?
Tell us the differences between an interface and an abstract class in .net?