remove item from code behind

5 posts, 1 answers
  1. robert
    robert avatar
    6 posts
    Member since:
    Dec 2008

    Posted 21 Jun 2009 Link to this post

    Dear Telerik,

    I'm trying to remove the item "EmployeeInformation" from the code behind. However I can't get it working.

    I have tried (as within the example "add remove items"):
    RadPanelItem item = RadPanelBar1.FindItemByValue("EmployeeInformation");
    item.Owner.Items.Remove(item);
    But this doesn't work.

    Could you give me a clue?

    The code I'm using:
    <telerik:RadPanelBar runat="server" ID="RadPanelBar1" ExpandMode="SingleExpandedItem" Width="800px" onprerender="RadPanelBar1_PreRender" oninit="RadPanelBar1_Init">
        <Items>
          <telerik:RadPanelItem Expanded="True" Text="Step 1: General information" runat="server" Selected="true">
            <Items>
              <telerik:RadPanelItem Value="GeneralInformation" runat="server">
                <ItemTemplate>
                  <asp:Button runat="server" ID="nextButton" OnClick="nextButton_Click" Text="Next" ValidationGroup="accountValidation" />
                </ItemTemplate>
              </telerik:RadPanelItem>
            </Items>
          </telerik:RadPanelItem>
          <telerik:RadPanelItem Enabled="True" Text="Step 2: Employee information" runat="server">
            <Items>
              <telerik:RadPanelItem Value="EmployeeInformation" runat="server">
                <ItemTemplate>
                </ItemTemplate>
              </telerik:RadPanelItem>
            </Items>
          </telerik:RadPanelItem>
           <telerik:RadPanelItem Enabled="False" Text="Step 3: Account information" runat="server">
            <Items>
              <telerik:RadPanelItem Value="AccountInformation" runat="server">
                <ItemTemplate>
                  <asp:Button runat="server" ID="registerButton" OnClick="registerButton_Click" Text="Register" ValidationGroup="TermsValidation" />
                </ItemTemplate>
              </telerik:RadPanelItem>
            </Items>
          </telerik:RadPanelItem>
        </Items>
        <CollapseAnimation Duration="100" Type="None" />
        <ExpandAnimation Duration="100" Type="None" />
      </telerik:RadPanelBar>
  2. -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 21 Jun 2009 Link to this post

    Hi robert,

    Your code works at my end.
    What event are you using to remove the item?

    Regards,
    -DJ-
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. robert
    robert avatar
    6 posts
    Member since:
    Dec 2008

    Posted 21 Jun 2009 Link to this post

    I have tried the following events:
    RadPanelBar1_PreRender
    RadPanelBar1_Init
    Page_Init
    Page_Load

    I hope I missed one, which would make the solution easier.




  5. Answer
    -DJ-
    -DJ- avatar
    263 posts
    Member since:
    Oct 2004

    Posted 21 Jun 2009 Link to this post

    Hi robert,

    I just threw it in page_load and it worked.

    Is is possible that you are confusing the items, and that you actually want to hide the parentitem of the EmployeeInformation Item?
    The parentitem has the text: "Step 2: Employee information", but it's not the item with the value EmployeeInformation...

    Regards,
    -DJ-
  6. robert
    robert avatar
    6 posts
    Member since:
    Dec 2008

    Posted 21 Jun 2009 Link to this post

    Wonderful, that worked. Sorry for the mistake.

    Cheers,

    Robert.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017