views:

744

answers:

1

Should controls in RadGrid's CommandItemTemplate maintain the state. I have template below and after posting back controls revert to initial state. ViewState is not turned of on the page level or on the grid.

 <CommandItemTemplate>
      <div class="gridActions">
         Notes
         <asp:DropDownList ID="cmdFilterNoteType" runat="server" AutoPostBack="false" />
         <asp:CheckBox ID="cmdShowAll" runat="server" AutoPostBack="true" OnCheckedChanged="cmdShowAll_CheckedChanged" Text="Show Latest Only" EnableViewState="true" />
      </div>
 </CommandItemTemplate>
A: 

If nothing happens on postback then state should be maintained. However, if the RadGrid rebinds its data source (using the NeedDataSource event, or some other method), the state would revert back to its initial setting. You can detect this by running your page in Debug mode and putting a breakpoint in the NeedDataSource or ItemDataBound events.

If this is happening and you want to maintain the previous state, then be sure to save the current state of the CommandItemTemplate before the grid is rebound, and then set it again in the grid_ItemDataBound event.

Yaakov Ellis