<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Alessandro Zifiglio : gridview</title><link>http://weblogs.asp.net/alessandro/archive/tags/gridview/default.aspx</link><description>Tags: gridview</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Custom Serverside paging in GridView Vs DataGrid</title><link>http://weblogs.asp.net/alessandro/archive/2007/10/09/custom-serverside-paging-in-gridview-vs-datagrid.aspx</link><pubDate>Tue, 09 Oct 2007 15:29:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:4511243</guid><dc:creator>alessandro</dc:creator><author>alessandro</author><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alessandro/rsscomments.aspx?PostID=4511243</wfw:commentRss><comments>http://weblogs.asp.net/alessandro/archive/2007/10/09/custom-serverside-paging-in-gridview-vs-datagrid.aspx#comments</comments><description>&lt;P&gt;&amp;nbsp;When doing serverside paging(that is paging at the database layer by returning only the paged result), one of the things I miss in the GridView control is the VirtualItemCount, which is supposedly only supported in the&amp;nbsp;older control's like the DataGrid. &lt;BR&gt;&lt;BR&gt;This property was quite useful because while being able to supply to the DataGrid a variable number of paged result sets, i was also able to tell the DataGrid, the total number of records, that way it knew how many pager buttons to display. &lt;BR&gt;&lt;BR&gt;Eg. If we had, say a total of a 100 records and had the pageSize set to 7, so only 7 records are shown at a time, then how does the grid know how many numbered pager buttons to display allowing us to navigate from one page to another ? That's where the VirtualItemCount came into play and saved the day. To this property we'd pass a total records count and that was it. In the GridView today ? There is no VirtualItemCount present. The way it were planned it seems is to use the ObjectDataSource, which in my honest opinion is simply extra work, however it does abstract much of this code nicely and put it where it should be, in the data tier.&lt;BR&gt;&lt;BR&gt;In all the example code in this post, I shall be using the MemberShip.GetAllUsers method. This method is overloaded and can retrieve a paged result of users Versus returning all the user's in the database, which is a quite handy overload and works out nicely for the code i want to use in this post.&lt;BR&gt;&lt;BR&gt;Let's look at a simple example of how we couldof performed custom paging on the DataGrid control back in the old days : &lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Page_Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, EventArgs e)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;IsPostBack)&lt;BR&gt;        {&lt;BR&gt;            DataGridMembers.DataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;, &lt;BR&gt;        DataGridMembers.PageSize, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount);&lt;BR&gt;            DataGridMembers.VirtualItemCount &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount;&lt;BR&gt;            DataGridMembers.DataBind();&lt;BR&gt;        }&lt;BR&gt;    }&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Note the VirtualItemCount ? Then on the PageIndexChanged event of the DataGrid we did :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; DataGridMembers_PageIndexChanged(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; source, &lt;BR&gt;    DataGridPageChangedEventArgs e)&lt;BR&gt;    {&lt;BR&gt;        DataGridMembers.CurrentPageIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; e.NewPageIndex;&lt;BR&gt;        DataGridMembers.DataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(e.NewPageIndex, &lt;BR&gt;    DataGridMembers.PageSize, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount);&lt;BR&gt;        DataGridMembers.DataBind();&lt;BR&gt;    }&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And that was it, it was as simple as that :-) &lt;BR&gt;&lt;BR&gt;&lt;BR&gt;Now try to do that on the GridView ? Can't be done and this is a control that is replacing the old DataGrid control. To make things worse, the DataGrid is not a supported control anymore in 2.0 ; It's been obsoleted and by default you wont even find this control in your toolbox. You can still use it however by manually adding it to your toolbox. Unfortunate, because there are moments like this custom paging situation and i'm getting nostalgic already.&lt;BR&gt;&lt;BR&gt;So, how to achieve the same thing in the GridView control which happens to replace the DataGrid ? Well, it's a long shot. Since we cannot achive this directly on the GridView, we are going to have to do it via the DataSource control, which is actually the control that is populating the data for the gridview and also the control that handles paging and sorting amoung other things. While i like this kind of data abstraction, i'm actually doing more work and making the extra effort,but this is how you would implement custom paging on&amp;nbsp; your GridView control.&lt;/P&gt;
&lt;P&gt;The GridView alone is lacking a VirtualItemCount property, which i believe shouldn't have been so hard to implement. To compensate for this lacking, you perform custom serverside paging by using an ObjectDataSource control, defining a SelectMethod and a SelectCountMethod method. The SelectCountMethod is your custom method that returns the Total records count. &lt;BR&gt;&lt;BR&gt;So let's look at some code, and there are few gotcha's that weren't exactly obvious to me in the begining : &lt;BR&gt;First our custom SelectMethod :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; MembershipUserCollection GetAllUsers(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex, &lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;)&lt;BR&gt;            startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(startRowIndex, &lt;BR&gt;            maximumRows, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue);&lt;BR&gt;    }&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;One gotcha you want to make note of is how i have some extra code to divide startRowIndex by maximumRows ; This is because startRowIndex is actually the first row in the resultset as the variable name indicates, however what i really need is the current page index, because that is what our stored procedure is expecting, in this case that is what the internal MemberShip.GetAllUsers method is expecting.&lt;BR&gt;&lt;BR&gt;Next we need to add a SelectCountMethod : &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; SelectVirtualCount()&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue;&lt;BR&gt;    }&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;The code is minimum as you can note, but ofcourse, there is some extra effort to making the abstraction. The code above goes into the data layer.&lt;BR&gt;&lt;BR&gt;And lastly, we need to subscribe to PageIndexChanging event of our GridView and pass the selected page index : &lt;BR&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; GridViewMembers_PageIndexChanging(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, &lt;BR&gt;    GridViewPageEventArgs e)&lt;BR&gt;    {&lt;BR&gt;        GridViewMembers.PageIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; e.NewPageIndex;&lt;BR&gt;    } &lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;A peculiar behaviour you will notice is that the SelectCountMethod and the SelectMethod both share the same SelectParameters if SelectParameters are defined. Peculiar because i was not really expecting it, however I have no issues with it, For example if we had to rewrite our previous example to include also a search by userName, then our ObjectDataSource would be expecting some SelectParameters like this :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ObjectDataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ObjectDataSourceMembers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        EnablePaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="True"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        SelectCountMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="SelectVirtualCount"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        SelectMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GetAllUsers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        TypeName&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="MembersData"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;        runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;SelectParameters&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ControlParameter &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ControlID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="TextBoxUserName"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="userName"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;        PropertyName&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="Text"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; DefaultValue&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="All"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;SelectParameters&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ObjectDataSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And then modified our SelectMethod as such : &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; MembershipUserCollection GetAllUsers(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex, &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; userName)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;)&lt;BR&gt;            startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (userName &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;==&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;all&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;)&lt;BR&gt;        {&lt;BR&gt;            &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(startRowIndex,&lt;BR&gt;                maximumRows, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue);&lt;BR&gt;        }&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;else&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        {&lt;BR&gt;                &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (MembershipUserCollection)&lt;BR&gt;                    Membership.FindUsersByName(userName &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;+&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;, &lt;BR&gt;                    startRowIndex, maximumRows, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue);&lt;BR&gt;        }&lt;BR&gt;    }&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see while our GetAllUsers(SelectMethod) has the needed userName parameter, our SelectVirtualCount method defined above does not have any parameters defined on it, since we don't need to pass it anything. However, the ObjectDataSource is going to complain with : &lt;BR&gt;&lt;BR&gt;ObjectDataSource 'ObjectDataSourceMembers' could not find a non-generic method 'SelectVirtualCount' that has parameters: userName&lt;BR&gt;&lt;BR&gt;So it means both the SelectMethod and the SelectCountMethod share the same Select parameters. I resolved by adding the extra userName parameter in the SelectCountMethod as well, while i did not clearly need it, but no big deal.&lt;BR&gt;Here is what the modified SelectCountMethod wouldof looked like :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; SelectVirtualCount(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; userName)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue;&lt;BR&gt;    }&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;The SelectCountMethod is treated exactly in the same way the SelectMethod is treated, so the ObjectDataSource's Selected Event is going to fire twice for example, once when the SelectMethod is called and once when the SelectCountMethod is called. These are all gotchas i was not really prepared for. &lt;BR&gt;&lt;BR&gt;Full code for custom serverside paging in DataGrid :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;@ Page Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;C#&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,255)"&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &lt;BR&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;&lt;BR&gt;   &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Page_Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, EventArgs e)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;IsPostBack)&lt;BR&gt;        {&lt;BR&gt;            DataGridMembers.DataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;, &lt;BR&gt;        DataGridMembers.PageSize, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount);&lt;BR&gt;            DataGridMembers.VirtualItemCount &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount;&lt;BR&gt;            DataGridMembers.DataBind();&lt;BR&gt;        }&lt;BR&gt;    }&lt;BR&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; DataGridMembers_PageIndexChanged(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; source, &lt;BR&gt;    DataGridPageChangedEventArgs e)&lt;BR&gt;    {&lt;BR&gt;        DataGridMembers.CurrentPageIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; e.NewPageIndex;&lt;BR&gt;        DataGridMembers.DataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(e.NewPageIndex, &lt;BR&gt;        DataGridMembers.PageSize, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; virtualItemCount);&lt;BR&gt;        DataGridMembers.DataBind();&lt;BR&gt;    }&lt;BR&gt;   &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;Untitled Page&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="form1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:DataGrid &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="DataGridMembers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; AllowPaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="True"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;        AllowCustomPaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="true"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; PageSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="2"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;        OnPageIndexChanged&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="DataGridMembers_PageIndexChanged"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;PagerStyle &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;Mode&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="NumericPages"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;                     HorizontalAlign&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="Right"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:DataGrid&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;And the full code for custom paging in GridView : &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;@ Page Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;C#&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;@ Import Namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;System.Data&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;@ Import Namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;System.Data.SqlClient&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,255)"&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &lt;BR&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; GridViewMembers_PageIndexChanging(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, &lt;BR&gt;    GridViewPageEventArgs e)&lt;BR&gt;    {&lt;BR&gt;        GridViewMembers.PageIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; e.NewPageIndex;&lt;BR&gt;    }&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;Untitled Page&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="form1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:GridView &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GridViewMembers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; DataSourceID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ObjectDataSourceMembers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;    runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; AllowPaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="True"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; PageSize&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="2"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;    OnPageIndexChanging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GridViewMembers_PageIndexChanging"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:GridView&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ObjectDataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ObjectDataSourceMembers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        EnablePaging&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="True"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        SelectCountMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="SelectVirtualCount"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        SelectMethod&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GetAllUsers"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;&lt;BR&gt;        TypeName&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="MembersData"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;BR&gt;        runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ObjectDataSource&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; MembersData&lt;BR&gt;{&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; MembersData()&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; TODO: Add constructor logic here&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    }&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;;&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; SelectVirtualCount()&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue;&lt;BR&gt;    }&lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; MembershipUserCollection GetAllUsers(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex, &lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows)&lt;BR&gt;    {&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;)&lt;BR&gt;            startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; startRowIndex &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; maximumRows;&lt;BR&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Membership.GetAllUsers(startRowIndex, &lt;BR&gt;            maximumRows, &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;out&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; selectCountValue);&lt;BR&gt;    }&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=4511243" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alessandro/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/alessandro/archive/tags/gridview/default.aspx">gridview</category><category domain="http://weblogs.asp.net/alessandro/archive/tags/DataGrid/default.aspx">DataGrid</category></item><item><title>ImageButton Control nested in a GridView Control throws EventValidation error.</title><link>http://weblogs.asp.net/alessandro/archive/2007/09/30/imagebutton-control-nested-in-a-gridview-control-throws-eventvalidation-error.aspx</link><pubDate>Sun, 30 Sep 2007 22:54:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:4260887</guid><dc:creator>alessandro</dc:creator><author>alessandro</author><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/alessandro/rsscomments.aspx?PostID=4260887</wfw:commentRss><comments>http://weblogs.asp.net/alessandro/archive/2007/09/30/imagebutton-control-nested-in-a-gridview-control-throws-eventvalidation-error.aspx#comments</comments><description>&lt;P&gt;Ever try to include an ImageButton control in your gridview and then end up with the following beautiful error message : &lt;/P&gt;
&lt;P&gt;Invalid postback or callback argument. Event validation is enabled using &amp;lt;pages enableEventValidation="true"/&amp;gt; in configuration or &amp;lt;%@ Page EnableEventValidation="true" %&amp;gt; in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. &lt;/P&gt;
&lt;P&gt;Thats right, its an EventValidation issue. This also occurs only with an ImageButton nested in a gridview. Moreover, you must be calling DataBind on the gridview if its a postback as well. Code speaks a thousand words, so lets look an example when this could occur : &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:939f6f6a-5e97-4db2-ac46-6f191a74840d contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;&amp;lt;%&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;@ Page Language&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;C#&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(245,245,245)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,255,0)"&gt;%&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,255)"&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:9865d532-6d10-4675-ba55-6b2baaa23e5e contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 1&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Page_Load(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, EventArgs e)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 2&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 3&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;if (!IsPostBack)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 4&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,128,0)"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;{&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 5&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,128,0)"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;            BindGrid();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 6&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;}&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 7&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,128,0)"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 8&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;private&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; BindGrid()
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt; 9&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;10&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        ArrayList al &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;new&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; ArrayList();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;11&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        al.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;a&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;12&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        al.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;b&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;13&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        al.Add(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;c&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;14&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        GridView1.DataSource &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; al;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;15&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;        GridView1.DataBind();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;16&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    }
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;17&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;18&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; ImageButton1_Click(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, EventArgs e)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;19&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    {
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;20&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;    }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d2d3487b-91af-4bdd-b36e-949615a1edc4 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;

&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="http://www.w3.org/1999/xhtml"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;Untitled Page&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;title&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;head&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="form1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:GridView  &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GridView1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; OnRowDataBound&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="GridView1_RowDataBound"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:ImageButton &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ImageButton1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; OnCommand&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ImageButton1_Click"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="server"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(255,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;ItemTemplate&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:TemplateField&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;Columns&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;asp:GridView&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
     &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; 
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;form&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;body&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;html&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;

&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;As you can see from the following sample code, we are rebinding our grid even on a postback, this means when the user posts back via our ImageButton, the grid will get rebound again. When this happens the gridview will recreate the gridview Vs pulling values from viewstate. By calling DataBind again in the page_load method, the Gridview recreates the child controls, and by the time our page gets to the Postback event handling phase, RaisePostBackEvent is fired in our imagecontrol(since it implements the IPostBackEventHandler interface). RaisePostBackEvent is what calls the ValidateEvent method, with two arguments. 1st argument is the UniqueID of our ImageButton and the second argument is a string argument. The issue here is with the UnqiueID argument. It has the id of the wrong control. How, why, I dont know exactly. I just know that by the time the ImageControl reaches the render phase, it has the correct uniqueID again. Since the gridview is a templated control, it prefixes the control with a unique namespace which happens to be the rowID of the current row which gets appeneded along with the gridview's id. Its this row id going wrong somehow only during RaisePostBackEvent. Happens only with the gridview too. I have tested with a repeater for eg and this worked correctly without issues. The 3-4 possible solutions I can think of are : &lt;/P&gt;
&lt;P&gt;1. Put an IsPostBack check and only bind the gridview if its a postback. This means the gridview will be repopulating from viewstate which obviously does not have this wrong rowid issue. So if you remove the comments from our previous code, your set. But not always populating from viewstate might be an option. &lt;/P&gt;
&lt;P&gt;2. You can try setting a unique id for the row generated by the ItemTemplate in our gridview. YOu can try this in either the RowCreated method or the RowDataBound method. In this manner we do not depend anymore on INamingContainer generating a uniqueID for the row, which in turn gets prefixed on our control since the row is now the direct NamingContainer and the problem is solved, eg : &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:dbcf2857-97aa-413d-b7ef-a2f2c04c5277 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;1&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; GridView1_RowCreated(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;object&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; sender, GridViewRowEventArgs e)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;2&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;{
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;3&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; (e.Row.RowType &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;==&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; DataControlRowType.DataRow)
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;4&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;e.Row.ID &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; e.Row.RowIndex.ToString();
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,128)"&gt;5&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,0)"&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;P&gt;and a&amp;nbsp;3rd way to work around this problem is to rebind the gridview at a later stage, a stage after &lt;STRONG&gt;RaisePostBackEvent&lt;/STRONG&gt; has finished executing. Since EventValidation is called during this stage, its safe to rebind after this call. Meaning for eg, in the OnCommand/onclick event of our ImageButton or in the RowCommand method of the gridview. In short, calling rebind on the grid after the Postback event handling phase will resolve your issues. Also note that this issue is there only with the ImageButton, the same does not happen if you used a LinkButton for eg, or a Button control. &lt;/P&gt;
&lt;P&gt;And&amp;nbsp;yet a 4th way to work around this is to use a LinkButton control and nest an image in it making it behave like an ImageButton. &lt;/P&gt;
&lt;P&gt;So why does this happen only with the ImageButton control ? This is because the ImageButton implements &lt;STRONG&gt;IPostBackDataHandler&lt;/STRONG&gt; interface. Image elements unlike other form elements include the x,y co-ordinates location in the image where you clicked. In order to detect this change and raise an event, the ImageButton control needs to provide implementation for &lt;STRONG&gt;LoadPostData&lt;/STRONG&gt; method. Also this is the same place where a call is being made for &lt;STRONG&gt;RegisterRequiresRaiseEvent&lt;/STRONG&gt;. &lt;STRONG&gt;RegisterRequiresRaiseEvent&lt;/STRONG&gt; is also the cause of the issue here. Without this call we have no problems with the uniqueID of the ImageControl, which is what made EventValidation to choke because the control was registered for EventValidation with one ID and then checked for Validation after validation with another ID. For me this unusual behaviour is a bug. We can make a simple test as the code that follows and the output of that code is not surprisingly the following and in this order : &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;LoadPostData: GridView1&lt;FONT color=#ff0000&gt;:_ctl2&lt;/FONT&gt;:ImageButton1&lt;/LI&gt;
&lt;LI&gt;RaisePostBackEvent: GridView1&lt;FONT color=#ff0000&gt;:_ctl4&lt;/FONT&gt;:ImageButton1&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;AddAttributesToRender: GridView1&lt;FONT color=#ff0000&gt;:_ctl2&lt;/FONT&gt;:ImageButton1 &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Notice how in RaisePostBackEvent, the id of the control has changed magically and is now GridView1&lt;FONT color=#ff0000&gt;:_ctl4&lt;/FONT&gt;:ImageButton1. &lt;STRONG&gt;RaisePostBackEvent&lt;/STRONG&gt; is also the method that registers the control for EventValidation. Notice that in a later phase &lt;STRONG&gt;AddAttributesToRender&lt;/STRONG&gt;, the control id is back again to what it was, and this is also asif by magic! For me this is a bug. Also the cause is none other than the call being made to &lt;STRONG&gt;RegisterRequiresRaiseEvent&lt;/STRONG&gt; from within &lt;STRONG&gt;LoadPostData&lt;/STRONG&gt;, which you can test by following the inline comments i have included in the &lt;STRONG&gt;LoadPostData&lt;/STRONG&gt; method. &lt;/P&gt;
&lt;P&gt;Following is the code to verify this behaviour : &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=wlWriterSmartContent id=57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:dfd2f90f-3f43-4538-9bbc-2cba5393ce77 contentEditable=false style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px"&gt;&lt;PRE style="BACKGROUND-COLOR: white"&gt;&lt;DIV&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Data;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Configuration;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web.Security;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web.UI;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web.UI.WebControls;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web.UI.WebControls.WebParts;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;using&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; System.Web.UI.HtmlControls; 

&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; Test
{
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;summary&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; Summary description for CustomImageButton
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;///&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;&amp;lt;/summary&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,128,128)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;[SupportsEventValidation]
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; CustomImageButton : ImageButton
{
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;public&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; CustomImageButton()
{
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; TODO: Add constructor logic here
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;} 

&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;override&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;bool&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; LoadPostData(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
HttpContext.Current.Response.Write(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;lt;br/&amp;gt;LoadPostData: &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;+&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;.UniqueID);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;return&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;base&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;.LoadPostData(postDataKey, postCollection);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; The reason this control chokes is because of the call being made to RegisterRequiresRaiseEvent.
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; To test this, first commentout the call to 
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; return base.LoadPostData(postDataKey, postCollection); above and then
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; remove the following comments below and and try it. It will work without issues!&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
/*&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;if (this.Page != null)
{
this.Page.RegisterRequiresRaiseEvent(this);
} 

return false;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;*/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;
}
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;override&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; RaisePostBackEvent(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;string&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; eventArgument)
{
HttpContext.Current.Response.Write(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;lt;br/&amp;gt;RaisePostBackEvent: &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;+&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;.UniqueID);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; base.RaisePostBackEvent is what actually registers this control for EventValidation
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; so dont call it in order to test this unexpected behaviour, otherwise, event
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt; validation will occur and you will get an error ofcourse :D
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;//&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;base.RaisePostBackEvent(eventArgument);&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,128,0)"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;}
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;protected&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;override&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;void&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; AddAttributesToRender(HtmlTextWriter writer)
{
HttpContext.Current.Response.Write(&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;&amp;lt;br/&amp;gt;AddAttributesToRender: &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;+&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;.UniqueID);
&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;base&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,0)"&gt;.AddAttributesToRender(writer);
}
}
} 
&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=4260887" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/alessandro/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/alessandro/archive/tags/gridview/default.aspx">gridview</category><category domain="http://weblogs.asp.net/alessandro/archive/tags/Invalid+postback/default.aspx">Invalid postback</category></item></channel></rss>