How to Bind GridView with DataReader.

Binding a large amount of data to a datagrid will take more time , to avoid the time delay of binding large amount of data we can use DataReader instead of DataSet or DataTable.By Default , Datareader is fast compared to DataSet or DataTable.

The following example shows how to bind GridView with DataReader.


SqlConnection Conn = new SqlConnection ("");
SqlCommand Comm = new SqlCommand("",Conn);

DataGrid1.DataSource = Comm.ExecuteReader();
DataGrid1.DataBind();


Comments

Author: Kapil Dhawan17 Jun 2008 Member Level: Gold   Points : 2

Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side

This code is going to help lots of guys to understand this concet too. as most of understand Grid can be bind with DS only

Regards,
Kapil



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: