I tested this solution, but I think the path is Css, this will put the visible false count() - 1 :
Put the update panel in your grid
<asp:UpdatePanel runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:BoundField DataField = "ProductName" HeaderText="A" /> <asp:BoundField DataField = "CategoryName" HeaderText="B" /> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> //Put this when you populate the grid ViewState["X"] = GridView1.Rows.Count; ViewState["Y"] = 1;
And in your button put this:
protected void btnReceive_Click(object sender, EventArgs e) { int X = int.Parse(ViewState["X"].ToString()); int Y = int.Parse(ViewState["Y"].ToString()); if (Y < GridView1.Rows.Count ) { GridView1.Rows[X - Y].Visible = false; ViewState["Y"] = Y + 1; } }
If you need to show the lines again, create another method with gvrow.Visible = true;
I don't know if this is the best, but it works. Hope to help.
source share