Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following is the code that I have written:-
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      SqlCommand com1 = new SqlCommand("quot;select sno,adv,city from adv1 where categry=@b",con);
      com1.Parameters.AddWithValue("@b", DropDownList1.Text);
      con.Open();
      GridView1.DataSource = com1.ExecuteReader();
      con.Close();
      GridView1.DataBind();
}


And under grid view I have the following:
C#
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.AllowPaging = true;
    }

It gives this error: "The data source does not support server-side data paging."
anyone can help?
Posted
Updated 16-Feb-11 3:46am
v4

In order to have paging you need to use DataAdapter. ExecuteReader is forward only, connected data form. Thus you won't be able to have server side pagin.

UPDATE:
Similar discussions: Link 1[^], Link 2[^]

Try something like:
DataTable dt = new DataTable();       
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
 
Share this answer
 
v2
Comments
vikas_3000 16-Feb-11 10:50am    
thank you
i try dataset earlier but that also not works but this is working thanks again
Take your error message (the part between the quotes) and paste it into the search box of your favourite internet search engine then hit return.

You will find almost all the possible solutions in the hits that you get.

Have a read until you find one that works for your situation.
 
Share this answer
 
You can try as bellow:


C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      SqlCommand com1 = new SqlCommand("select sno,adv,city from adv1 where categry=@b",con);
      com1.Parameters.AddWithValue("@b", DropDownList1.Text);
      con.Open();

      SqlDataAdapter da=new SqlDataAdapter(com1); 
      DataSet ds=new DataSet();
      da.Fill(ds);
      GridView1.DataSource = ds.Tables[0];
      GridView1.DataBind();
      con.Close();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //GridView1.PageIndex = e.NewPageIndex; //with or without
        GridView1.AllowPaging = true;
    }


Thanks,
Mamun
 
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