Object reference not set to an instance of an object in Gridview
<p>i Have a grid name=gvDetails in that grid i have a dropdown also for page navigation</p>

<pre><code>protected void gvDetails_DataBound(object sender, EventArgs e)
{
    GridViewRow pagerRow = gvDetails.BottomPagerRow;
   DropDownList pageList = 
</code></pre>

<blockquote>
  <p>(DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");</p>
</blockquote>

<pre><code>    Label pageLabel = (Label)pagerRow.Cells[0].FindControl("CurrentPageLabel");
    if (pageList != null)
    {
        for (int i = 0; i &lt; gvDetails.PageCount; i++)
        {
            int pageNumber = i + 1;
            ListItem item = new ListItem(pageNumber.ToString());
            if (i == gvDetails.PageIndex)
            {
                item.Selected = true;
            }
            pageList.Items.Add(item);
        }
    }
    if (pageLabel != null)
    {
        int currentPage = gvDetails.PageIndex + 1;
    }
}
</code></pre>

<p>-----<strong><em>*</em>**<em>*</em>**</strong>----------</p>

<p>This Is the fill coding i have</p>

<pre><code>protected void gvDetails_DataBound(object sender, EventArgs e)
{
    GridViewRow pagerRow = gvDetails.BottomPagerRow;
    DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
    Label pageLabel = (Label)pagerRow.Cells[0].FindControl("CurrentPageLabel");
    if (pageList != null)
    {
        for (int i = 0; i &lt; gvDetails.PageCount; i++)
        {
            int pageNumber = i + 1;
            ListItem item = new ListItem(pageNumber.ToString());
            if (i == gvDetails.PageIndex)
            {
                item.Selected = true;
            }
            pageList.Items.Add(item);
        }
    }
    if (pageLabel != null)
    {
        int currentPage = gvDetails.PageIndex + 1;
    }
}
protected void PageDropDownList_SelectedIndexChanged(Object sender, EventArgs e)
{
    GridViewRow pagerRow = gvDetails.BottomPagerRow;
    DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
    gvDetails.PageIndex = pageList.SelectedIndex;
}
private void LoadBindGrid()
{
    ////Set your connection String here
    SqlConnection CN = DBUtil.GetCon();
    if (CN.State != ConnectionState.Closed)
        CN.Close();
    CN.Open();
    string q = "SELECT Head_Code,Head_Name,Section_Code,Head_Mode,Head_Type,Head_Status FROM eLogs_Acc_Account_Master";
    SqlCommand cmd = new SqlCommand(q, CN);
    //SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=Northwind;Integrated Security=True");
    ////Write a select Query
    //string q = "select CustomerID,CompanyName,ContactName,Phone,City,Country  from Customers";
    DataSet dset = new DataSet();
    SqlDataAdapter da = new SqlDataAdapter(q, CN);
    //cn.Open();
    DataTable dtable = new DataTable();
    da.Fill(dtable);
    //Bind grid.
    gvDetails.DataSource = dtable;
    gvDetails.DataBind();
    CN.Close();
}
</code></pre>

<p>Object reference not set to an instance of an object. IE., from line NO 4( DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");)
help please</p>
