Event Problem inside grid view
<p>i want to provide custom paging in grid view...</p>

<pre><code> &lt;asp:GridView ID="gvFirst" runat="server" AutoGenerateColumns="false" 
        AllowPaging="true" 
        ondatabound="gvFirst_DataBound" &gt;
        &lt;Columns&gt;
            &lt;asp:BoundField DataField="ID" HeaderText="ProductID"/&gt;
            &lt;asp:BoundField DataField="Name" HeaderText="ProductName" /&gt;
        &lt;/Columns&gt;
        &lt;PagerTemplate&gt;
            &lt;asp:Panel ID="pnlPager" runat="server"&gt;
            &lt;/asp:Panel&gt;
        &lt;/PagerTemplate&gt;
    &lt;/asp:GridView&gt;
</code></pre>

<p>If i create button here and bind click event then it is fire...but problem is this evet occur for each row bind with grid</p>

<pre><code>protected void gvFirst_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Pager)
        {
            Panel pnPager = e.Row.FindControl("pnlPager") as Panel;
            if (pnPager != null)
            {
                Button btnFirst = new Button();
                btnFirst.Text = "1";
                btnFirst.Click += new EventHandler(btnFirst_Click);
                pnPager.Controls.Add(btnFirst);
            }
        }
    }
</code></pre>

<p>/<em>If i create button here and bind click event then it is not fire...this event fire after all the rows bind to grid..so it will occur only once..</em>/</p>

<pre><code>protected void gvFirst_DataBound(object sender, EventArgs e)
    {
        GridViewRow gvRow = gvFirst.BottomPagerRow;
        if (gvRow != null)
        {
            Panel pnPager = gvRow.FindControl("pnlPager") as Panel;
            if (pnPager != null)
            {
                Button btnFirst = new Button();
                btnFirst.Text = "1";
                btnFirst.Click += new EventHandler(btnFirst_Click);
                pnPager.Controls.Add(btnFirst);
            }
        }
    }

    void btnFirst_Click(object sender, EventArgs e)
    {
        using (_NorthWindDataContext = new NorthWindDataContext())
        {
            var ProductInformation = from p in _NorthWindDataContext.Products
                                     select new
                                     {
                                         ID = p.ProductID,
                                         Name = p.ProductName
                                     };
            gvFirst.DataSource = ProductInformation.Skip(5).Take(5);
            gvFirst.DataBind();
        }
    }
</code></pre>

<p>pls help me to understand this...
<strong>Another problem which i am facing is</strong>...
i want to provide custom paging , now i have set page size to 5 and i am fetching 5 record from query so my grid pager is not display please help me out of this....it is urgent...</p>

<p>Hi Thanks For Help!</p>

<pre><code>public class Productinformation
{
    public int PID
    {
        get;
        set;
    }
    public string PName
    {
        get;
        set;
    }
}
 using (NorthWindDataContext _NorthWindDataContext = new NorthWindDataContext())
        {
            Proinfo = new List&lt;Productinformation&gt;();
            Proinfo = (from p in _NorthWindDataContext.Products
                       select new Productinformation
                       {
                           PID = p.ProductID,
                           PName = p.ProductName,
                       }).ToList();

            gvFirst.DataSource =  Proinfo.Take(PageSize) ;
            gvFirst.DataBind();
        }
</code></pre>

<p>Proinfo variable declare globaly...
Now When i bind i run this code it will give me error <strong>the data source does not support server-side data paging</strong> if i use var type of variable then it is worked but we can't declare var type of variable globaly,so i used it then i have to call this method every time in paging... and i don't want to use <strong>Objectdatasource</strong>
Help me....</p>
