In this article we will learn about Paging with a DropDownList in ASP.NET. Here runtime numbers will be shown in the DropDownList; when we choose a number, that number of records will be shown in the GridView. Here paging facilities are also provided to the GridView.
Table Creation

Default.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Paging_with_dropdownlist._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView id="g1" Runat="Server"
AllowPaging="True"
AutoGenerateColumns="true" onpageindexchanging="g1_PageIndexChanging" PagerStyle-Visible = "False" HeaderStyle-BackColor="Red"
HeaderStyle-ForeColor="White" BackColor="#FFCC66">
<HeaderStyle BackColor="Red" ForeColor="White"></HeaderStyle>
<AlternatingRowStyle BackColor="#FFFFCC" />
</asp:GridView>
<asp:Label ID="Label1" runat="server" Text="Choose No." Font-Bold="True"
ForeColor="#CC3300"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>



Dawood AbbasPosted Mar 12, 2015, 9:55 AM
throwing error at e.NewPageIndex;
Pratham DavePosted Sep 19, 2014, 5:30 AM
Great Work, Keep it up..
Maria JohnsonPosted Mar 1, 2012, 11:16 PM
Great what a presentation.
Abhishek DubeyPosted Feb 29, 2012, 11:16 PM
Really this is Great works thanks for sharing it.
Sanjoli GuptaPosted Feb 29, 2012, 11:01 PM
very well explained
Monika AroraPosted Feb 29, 2012, 10:53 PM
You have presented your article very nicely.
Amit MaheshwariPosted Feb 29, 2012, 10:47 PM
Hi, Satyapriya it's very well explanation about Paging, Having good concept about it. So keep it up and thanks for sharing.....
Arjun PanwarPosted Feb 29, 2012, 10:44 PM
Thanks for this great work.