tags:

views:

565

answers:

2
protected void rgStateTax_PreRender( object sender, EventArgs e )
{
    if( rgStateTax.MasterTableView.IsItemInserted )
    {
        foreach( GridItem item in rgStateTax.Items )
        {
            item.Visible = false;
        }
    }

    if( rgStateTax.EditItems.Count > 0 )
    {
        foreach( GridDataItem item in rgStateTax.Items )
        {
            if( item != rgStateTax.EditItems[0] )
            {
                item.Visible = false;
            }
        }
    }
}

Here, rgStateTax is a Rad grid control. Is there any reason for marking the items as invisible? PreRender is the event before the page is actually displayed on the screen, right?.

+2  A: 

PreRender is the event that takes place just before the HTML for a given control/page is generated (to later be sent to the browser). So by setting an item.Visible = false here it will not be rendered to the HTML (however it's ViewState will).

In this case it looks like the code is hiding all rows in the RadGrid when a user is editing/inserting an item I presume for less distractions for the end user.

Josh
i read that mastertableview means top table,,that means top row contents in first page of rad grid
peter
Means top row of grid orcontents in first page of rad grid,,Can you tell me about that
peter
Any way i got idea about what happend in pre render of rad grid here
peter
Not terribly familiar with RadGrid so all I could offer is a guess. I'm thinking when Inserting a new item with RadGrid it put's the new item as the first entry (eg top row of first page), and so testing it for IsItemInserted is basically asking "Am I trying to insert a new record?"
Josh
A: 

In the interest of teaching a man to fish:

http://blog.tieredsolutions.com/images/o_aspNet_Page_LifeCycle_s-1.jpg

This is your buddy. Learn to love it. :)

Chad Ruppert