How to set change DetailsView PagerSettings pager mode in asp.net

DetailsView PagerSettings pager mode
DetailsViewPagerSettingsMode.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        DetailsView1.PagerSettings.Mode = PagerButtons.NumericFirstLast;
    }    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>How to set change DetailsView PagerSettings pager mode in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">DetailsView Example: Set Pager Mode</h2>
        <asp:SqlDataSource 
            ID="SqlDataSource2"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="Select Top 10 ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock From Products"
            CancelSelectOnNullParameter="false"
            >
        </asp:SqlDataSource>
        <asp:DetailsView 
            ID="DetailsView1"
            runat="server"
            DataSourceID="SqlDataSource2"
            AllowPaging="true"
            ForeColor="Snow"
            BackColor="IndianRed"
            BorderColor="Tan"
            AutoGenerateRows="false"
            Width="475"
            Font-Names="Comic Sans MS"
            HeaderText="Product Details"
            >
            <PagerSettings Mode="NextPreviousFirstLast" />
            <PagerStyle 
                BackColor="DarkSalmon"
                Height="45"
                Font-Italic="true"
                HorizontalAlign="Right"
                Font-Size="Large"
                VerticalAlign="Top"
                />
            <HeaderStyle 
                BackColor="Crimson"
                BorderColor="IndianRed"
                Font-Bold="true"
                Font-Size="X-Large"
                HorizontalAlign="Center"
                Height="50"
                />
            <RowStyle 
                Height="35" 
                Font-Italic="true" 
                />
            <Fields>
                <asp:BoundField DataField="ProductID" HeaderText="Product ID" ReadOnly="true" />
                <asp:BoundField DataField="Productname" HeaderText="Product Name" />
                <asp:BoundField DataField="QuantityPerUnit" HeaderText="Quantity Per Unit" />
                <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" />
                <asp:BoundField DataField="UnitsInStock" HeaderText="Units In Stock" />
            </Fields>
        </asp:DetailsView>
        <br />
        <asp:Button 
            ID="Button1" 
            runat="server"
            Text="Change DetailsView Pager Mode"
            Height="45"
            Font-Bold="true"
            ForeColor="Peru"
            OnClick="Button1_Click"
            />        
    </div>
    </form>
</body>
</html>








Related asp.net example