HeaderStyle-BackColor="#87cfe6" AutoGenerateColumns="false" ForeColor="White"
AllowPaging="true" AllowSorting="true" PageSize="3" Width="100%">
and this is the code for .cs file
public partial class DeleteArticles : System.Web.UI.Page
{
string str = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
SqlConnection con;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvArt();
}
}
protected void gvArt()
{
con = new SqlConnection(str);
con.Open();
cmd = new SqlCommand("select * from Articles",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
gvArticles.DataSource = ds;
gvArticles.DataBind();
con.Close();
}
protected void gvArticles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
}
but when i try to change pageindex it doesn't change .
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Joxin StanlyPosted Aug 17, 2013, 8:07 AM
Amit KumarPosted Aug 17, 2013, 8:10 AM
Sanjeeb LenkaPosted Aug 17, 2013, 8:07 AM
in your code you forgot to bind the event. i modified your code check
PageSize="3" Width="100%"
OnPageIndexChanging="gvArticles_PageIndexChanging">
in .cs code:
protected void gvArticles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvArticles.PageIndex = e.NewPageIndex;
gvArt();
}