Hi,
You can find the control placed in pagerTemplate.
You have to do following thing in your code:
DropDownList drp =(DropDownList)
GridView1.BottomPagerRow.FindControl("DropDownList1");
Through this you can get controls placed in Pager Template.
ASP.net Control Code:
<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="First.ascx.cs" Inherits="First" Debug="true" %>
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="au_id">
<PagerTemplate >
<asp
ropDownList ID="DropDownList1" runat="server">
</asp
ropDownList>
</PagerTemplate>
<Columns>
<asp:BoundField DataField="au_id" HeaderText="au_id"
ReadOnly="True" SortExpression="au_id" />
<asp:BoundField DataField="au_lname" HeaderText="au_lname"
SortExpression="au_lname" />
<asp:BoundField DataField="au_fname" HeaderText="au_fname"
SortExpression="au_fname" />
<asp:BoundField DataField="address" HeaderText="address"
SortExpression="address" />
<asp:BoundField DataField="city" HeaderText="city"
SortExpression="city" />
<asp:BoundField DataField="state" HeaderText="state"
SortExpression="state" />
<asp:BoundField DataField="zip" HeaderText="zip"
SortExpression="zip" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName
%>" SelectCommand="SELECT [au_id], [au_lname], [au_fname], [address],
[city], [state], [zip] FROM [authors]">
</asp:SqlDataSource>
ASP.net Code Behind:
DropDownList drp =(DropDownList)
GridView1.BottomPagerRow.FindControl("DropDownList1");
for (int i = 1; i < 10; i++)
{
drp.Items.Add(new ListItem(i.ToString(),i.ToString()));
}
drp.DataBind();
I hope this solves your problem.
Ravi