Gridview paging?
-
Hi friends, I use a grid view for paging I write the coding like this. form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" BorderWidth="2px" BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White"> </asp:GridView> </div> </form> try { con.Open(); com=new SqlCommand("SELECT [ProductName], [UnitPrice],[UnitsInStock], [QuantityPerUnit] FROM [Products] order by [ProductName]",con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); ds.Dispose(); da.Dispose(); con.Close(); } catch (Exception ex) { Response.Write(ex.Message); } The datas are displayed. But when i click on the 2nd number, it shows a error The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Can anyone say where to handle this event?
-
Hi friends, I use a grid view for paging I write the coding like this. form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" BorderWidth="2px" BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White"> </asp:GridView> </div> </form> try { con.Open(); com=new SqlCommand("SELECT [ProductName], [UnitPrice],[UnitsInStock], [QuantityPerUnit] FROM [Products] order by [ProductName]",con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); ds.Dispose(); da.Dispose(); con.Close(); } catch (Exception ex) { Response.Write(ex.Message); } The datas are displayed. But when i click on the 2nd number, it shows a error The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Can anyone say where to handle this event?
Just do it ;)
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}cheers, Abhijit CodeProject MVP
-
Hi friends, I use a grid view for paging I write the coding like this. form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" BorderWidth="2px" BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White"> </asp:GridView> </div> </form> try { con.Open(); com=new SqlCommand("SELECT [ProductName], [UnitPrice],[UnitsInStock], [QuantityPerUnit] FROM [Products] order by [ProductName]",con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); ds.Dispose(); da.Dispose(); con.Close(); } catch (Exception ex) { Response.Write(ex.Message); } The datas are displayed. But when i click on the 2nd number, it shows a error The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Can anyone say where to handle this event?
-
Hi friends, I use a grid view for paging I write the coding like this. form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" BorderWidth="2px" BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White"> </asp:GridView> </div> </form> try { con.Open(); com=new SqlCommand("SELECT [ProductName], [UnitPrice],[UnitsInStock], [QuantityPerUnit] FROM [Products] order by [ProductName]",con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); ds.Dispose(); da.Dispose(); con.Close(); } catch (Exception ex) { Response.Write(ex.Message); } The datas are displayed. But when i click on the 2nd number, it shows a error The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Can anyone say where to handle this event?
-
Hi friends, I use a grid view for paging I write the coding like this. form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" BorderWidth="2px" BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White"> </asp:GridView> </div> </form> try { con.Open(); com=new SqlCommand("SELECT [ProductName], [UnitPrice],[UnitsInStock], [QuantityPerUnit] FROM [Products] order by [ProductName]",con); SqlDataAdapter da = new SqlDataAdapter(com); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); ds.Dispose(); da.Dispose(); con.Close(); } catch (Exception ex) { Response.Write(ex.Message); } The datas are displayed. But when i click on the 2nd number, it shows a error The GridView 'GridView1' fired event PageIndexChanging which wasn't handled Can anyone say where to handle this event?
see this Paging without a wizard (SqldataSource control) [^][^] Hope it Helps
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za www.ITS.co.za