Click here to Skip to main content
16,019,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i can take gridview on .aspx page..and bind data to the Grid by using bellow code..
my code..

cmd = new SqlCommand("select Username,Password,Department from Login",con);
SqlDataReader dr22 = cmd.ExecuteReader();
GridView1.DataSource = dr22;
GridView1.DataBind();

and i set property "Allow Paging=True" for gridview it gives following error..
"The data source does not support server side allow_paging"
please help
Posted
Updated 21-Feb-13 19:26pm
v4

Hi,

instead of DataReader, use DataTable as data source for gridview.
 
Share this answer
 
Because You Used Datareader which works in forward only manner.<br />
Use Dataset or Datatable[Dataadpter] which supports both forward and backward navigation.


C#
protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {

           Binddata();


       }
   }
   public void Binddata()
   {

   string connect=System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
   SqlConnection sqlconn = new SqlConnection(connect);
   SqlDataAdapter da = new SqlDataAdapter("select * from persons",sqlconn);
   DataSet ds = new DataSet();
   da.Fill(ds);
   sqlconn.Open();

   GridView1.DataSource = ds.Tables[0];
   GridView1.DataBind();

   sqlconn.Close();



   }


C#
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
   {
       GridView1.PageIndex = e.NewPageIndex;
       Binddata();

   }
 
Share this answer
 
v2
Why? Did you tried Google[^]?
Google is your friend and please use that to find your solution. There are many examples you can find over the internet.

Ok. Let me Google that for you[^].


--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900