Add Dropdown list to Edit Manager Programatically

2 posts, 0 answers
  1. Neal
    Neal avatar
    1 posts
    Member since:
    Sep 2016

    Posted 26 Oct 2016 Link to this post

    I have a RadGrid where the data source is set programmatically because the data source will change based on the option the user selects. Some data sources have more columns than the others. When I have the edit item panel displayed to insert a new record I am removing a text box and adding a drop down in its place and populating the drop down from the database and selecting the value that was in the textbox. I can get this to display but when I click the insert button the page blows up because when the page gets to the init event it wants to bind the old one. any advice on how I can get around this?

    here is a ajax error that I get every time I try and do an insert/update

    Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

  2. Eyup
    Eyup avatar
    3962 posts

    Posted 31 Oct 2016 Link to this post

    Hi Neal,

    Generally, when you are changing the grid columns dynamically, you can check the approach demonstrated in the following article:

    Adding and handling controls programmatically can be error-prone, therefore, you can use Panels and toggle their visibility depending on the dropdown's selection:
    Copy Code
    <EditFormSettings EditFormType="Template">
            <asp:Panel ID="GridInsertPanel" runat="server" Visible='<%# Container is IGridInsertItem %>'>
            <asp:Panel ID="GridEditPanel" runat="server" Visible='<%# !(Container is IGridInsertItem) %>'>

    in your case, instead of FormTemplate, you can use the EditItemTemplate of the GridTemplateColumn.

    I hope this will prove helpful.

    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top