We help IT Professionals succeed at work.
Get Started

gridview paging not displaying second page.

Mehram asked
Last Modified: 2012-08-12
I am using below mentioned code to display data into gridview. it is showing data of first page excellent. When I clicked on 2 page or any other page the gridview disappear to the web page and webpage blank.
Please help me where I am doing wrong/

 <asp:GridView ID="Invoicing" runat="server" AutoGenerateColumns="False"
        HeaderStyle-Font-Size="Medium" HeaderStyle-Font-Italic="true" CellPadding="1"
        ForeColor="#333333" GridLines="None" Width="908px"
        AllowPaging="True" PageSize="12" AllowSorting="True" EnableSortingAndPagingCallbacks="True"
        OnPageIndexChanging="Invoicing_PageIndexChanging" >       
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

 public partial class InvPage : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
        SqlConnection con;
        SqlCommand cmd;
        DataSet ds;
        SqlDataAdapter da;
        private void loadGrid()
             string values = "Select sno=Row_number() Over (Order by InvNo,Date), Date, InvNo, Amt=Sum(Amt), CoCom=Sum(Isnull(CoCom,0)), MkCom=Sum(Isnull(MkCom,0)), NPV=Sum(NetPurchasedValue), FreeStock from tempp Where FreeStock='0' Group by Date, InvNo, FreeStock Order by InvNo,Date";
            using (con = new SqlConnection(ConfigurationManager.ConnectionStrings["DLICCBPL"].ConnectionString))
                cmd = new SqlCommand(values,con);
                ds = new DataSet();
                da = new SqlDataAdapter(cmd);
                Invoicing.DataSource = ds;
                Invoicing.DataMember = "bb";                


        protected void Invoicing_PageIndexChanging(Object sender, GridViewPageEventArgs e)
            Invoicing.PageIndex = e.NewPageIndex;
            //((GridView)sender).PageIndex = e.NewPageIndex;


Watch Question
Developer User Interface
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE