ASP.NET Gridview Linkbutton Hiding/Display page load issue
<p>I am trying to hide/display a linkbutton in my gridview based on wether not the row in the Gridview is part of my shopping cart. </p>

<p>This is the gridview</p>

<pre><code>    &lt;asp:GridView ID="productListTable" runat="server" DataSourceID="srcProductListPerCustomer" AutoGenerateColumns="False" AlternatingRowStyle-CssClass="tr_dark"  HeaderStyle-CssClass="header_req" BorderWidth="0px" GridLines="None" AllowPaging="true" PageSize="25" EmptyDataText="No records." AllowSorting="false" Width="100%" DataKeyNames="product_ID_key" OnRowDataBound="productListTable_RowDataBound" OnRowCommand="productListTable_RowCommand"  &gt;         
    &lt;Columns&gt;                         
            &lt;asp:TemplateField HeaderText="Product Name" HeaderStyle-Width="250px" SortExpression="productName" ItemStyle-CssClass="product_name" &gt;
                &lt;ItemTemplate&gt;   
                &lt;asp:Label ID="ProductNameField" runat="server" Text='&lt;%# Eval("productName").ToString() %&gt;'&gt;&lt;/asp:Label&gt;
                &lt;/ItemTemplate&gt;                     
            &lt;/asp:TemplateField&gt; 

    &lt;/Columns&gt;
     &lt;Columns&gt;  

    &lt;asp:TemplateField HeaderText="Quantity"&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:TextBox runat="server" ID="txtQuantity" Columns="5"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;
                        &lt;asp:LinkButton runat="server" ID="btnRemove" Text="Remove" CommandName="Remove" CommandArgument='&lt;%# Eval("product_ID_key") %&gt;' style="font-size:12px;" Visible="false"&gt;&lt;/asp:LinkButton&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
    &lt;HeaderStyle CssClass="header_req" /&gt;
    &lt;AlternatingRowStyle CssClass="tr_dark" /&gt;
    &lt;PagerStyle CssClass="pagination" /&gt;
    &lt;PagerSettings PageButtonCount="3" FirstPageText="First" LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" Mode="NumericFirstLast" /&gt;      
&lt;/asp:GridView&gt;
</code></pre>

<p>The way I am trying to do this at the moment is by row data bound</p>

<pre><code>     Protected Sub productListTable_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles productListTable.RowDataBound
    ' If we are binding the footer row, let's add in our total
    If e.Row.RowType = DataControlRowType.DataRow Then
        'e.Row.Cells(6).Text = "Total Price: " &amp; ShoppingCart.Instance.GetSubTotal().ToString("C")
        Dim productId = Convert.ToInt32(productListTable.DataKeys(e.Row.RowIndex).Value)

        Dim txtQuantity As TextBox = CType(e.Row.Cells(1).FindControl("txtQuantity"), TextBox)
        Dim removeButton As LinkButton = CType(e.Row.Cells(1).FindControl("btnRemove"), LinkButton)

        Dim updatedItem = New CartItem(productId)

        For Each item As CartItem In ShoppingCart.Instance.Items
            If item.Equals(updatedItem) Then
                txtQuantity.Text = item.Quantity
                removeButton.Visible = True
            End If
        Next
    End If
End Sub
</code></pre>

<p>And it works fine, but not at the initial refresh of the page when adding a new product but only after a hard refresh I see the button appear. Do I need to perform this check in a different lifecycle or gridview event so i can see the update immediately ?</p>
