New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Hide All Rows on Insert and Display the Edit Form Only

When the grid presentation area is restricted on your page you may not want to display the grid items on item insertion (as thus the control will expand its height). To hide all rows in Telerik RadGrid on item insertion and display merely the edit form for the inserted item, you need to:

  1. Subscribe to the PreRender event of Telerik RadGrid

  2. Verify whether RadGrid1.MasterTableView.IsItemInserted is set to True

  3. Traverse the grid items and set their Visible attribute to False

<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server">
  <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="True" />
</telerik:RadGrid>
private void RadGrid1_PreRender(object sender, System.EventArgs e)
{
    if (RadGrid1.MasterTableView.IsItemInserted)
    {
        foreach (GridItem item in RadGrid1.Items)
        {
            item.Visible = false;
        }
    }
}
Private Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
    If RadGrid1.MasterTableView.IsItemInserted Then
        For Each item As GridItem In RadGrid1.Items
            item.Visible = False
        Next
    End If
End Sub
In this article