Getting error on Paging programatically in Asp.net Gridview
<p>I am creating paging on Asp.net Gridview programatically.I am getting the error "Microsoft JScript runtime error: 'grdAssetList_PageIndexChanged' is undefined" below is my code why the error is occuring i don't understand still. Please any on help me.</p>

<pre><code>if (ds.Tables[0].Rows.Count != 0)
    {
        setPages();
        int startRow = ((pageNumber - 1) * pageSize) + 1;
        int endRow = startRow + pageSize - 1;
        if (endRow &gt; rowCount) endRow = rowCount;
        lblNowShowing.Text = startRow.ToString("###,##0") + " to " + endRow.ToString("###,##0") + " of " + rowCount.ToString("###,##0");
    lblPageNum.Text = "Page " + txtCurrentPageIndex.Value + " of " + pageCount.ToString(); 
    }


protected void setPages(){        
    int pageCount = Convert.ToInt16(txtPageCount.Value);
    int currentPageIndex = Convert.ToInt16(txtCurrentPageIndex.Value);
    int startPageNum = 1;
    startPageNum = currentPageIndex - 3;
    if (startPageNum &lt; 1) startPageNum = 1;
    int endPageNum = startPageNum + 10;
    if (endPageNum &gt; pageCount) endPageNum = pageCount;
    PlaceHolder place = PlaceHolder1;
    place.Controls.Clear();
    for (int i = startPageNum; i &lt;= endPageNum; i++)
      {
        if (i == currentPageIndex){
            Label lblPage = new Label();
            lblPage.Text = currentPageIndex.ToString();
            place.Controls.Add(lblPage);
          } 
        else{
            HtmlAnchor btn = new HtmlAnchor();
        **btn.Attributes.Add("onclick", "grdAssetList_PageIndexChanged(" + i.ToString() + ")");** // Here i am getting error
            btn.InnerText = i.ToString();
            btn.Title = "Page " + i.ToString();
            btn.HRef = "#";
            place.Controls.Add(btn);
        }
          Label lbl = new Label();
          lbl.Text = " ";
          place.Controls.Add(lbl); }
}
</code></pre>

<p>on Grid allowpaging= true and OnPageIndexChanging="grdAssetList_PageIndexChanged"</p>
