3

Can anyone tell me the things happening in this section? Why is it making items invisible?

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 rad grid and PreRender is the event before the page is actually displayed on the screen, right?

Ageonix
  • 1,748
  • 2
  • 19
  • 32
peter
  • 8,158
  • 21
  • 66
  • 119

2 Answers2

0

Yes, PreRender is called before the control is rendered for the page.

This snippet of code is simply looping through almost every item in the grid and making it invisible.

if( rgStateTax.MasterTableView.IsItemInserted ) This checks if an item has been inserted into the grid.

foreach( GridItem item in rgStateTax.Items ) This loops through every item in the radgrid.

item.Visible = false; This sets each item to be invisible.

As for the next part:

if( rgStateTax.EditItems.Count > 0 ) This checks if there are any grid items in edit mode.

foreach( GridDataItem item in rgStateTax.Items ) This loops through every item in the radgrid (regardless if each item is in edit mode or not).

if( item != rgStateTax.EditItems[0] ) This checks if the current item is not the first item in edit mode (so we enter this for all but one item.

item.Visible = false; This sets each item to be invisible.

And that's what's happening.

Jimmy
  • 2,805
  • 6
  • 43
  • 57
0

You probably wanted

    if(!item.Edit){item.Visible = false;}
SarjanWebDev
  • 523
  • 3
  • 11