This is a migrated thread and some comments may be shown as answers.

Edit Form does not close after radcombobox autopostback

6 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 03 Jul 2013, 08:41 PM
Hello,

I have a custom form template in my RadGrid that closes fine right after opening (clicking on edit), but will not close after selecting an item in a combobox within the form (which is set to autopostback="true"). There are multiple linked comboboxes being used in the form, a form decorator and ajaxmanager with the RadGrid registered to the manager updating itself. I assume this is an issue with the ajax controls being used, but it does not appear obvious that there is any reason why the editform is not being collapsed after an autopostback.  My project implements code very similar to the demo here -> http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx.

Thank you for any input

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 05 Jul 2013, 06:38 AM
Hi Andrew ,

I tried to replicate the issue but no avail.Could you please provide your code for better understanding your issues.
Here is a sample i tried and it works fine at my side.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="false"  AllowAutomaticDeletes="True" AllowAutomaticInserts="True"            AllowAutomaticUpdates="True" >
           <MasterTableView CommandItemDisplay="TopAndBottom"
               DataKeyNames="OrderID">
               <Columns>
                   <telerik:GridEditCommandColumn>
                   </telerik:GridEditCommandColumn>
                   <telerik:GridBoundColumn UniqueName="OrderID" HeaderText="OrderID" DataField="OrderID">
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn UniqueName="ShipCity" HeaderText="ShipCity" DataField="ShipCity">
                   </telerik:GridBoundColumn>
                   <telerik:GridCheckBoxColumn UniqueName="IsTrue" HeaderText="IsTrue" DataField="IsTrue">
                   </telerik:GridCheckBoxColumn>
                   <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column">
                   </telerik:GridButtonColumn>
               </Columns>
               <EditFormSettings EditFormType="Template">
                   <FormTemplate>
                       <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                           style="border-collapse: collapse;">
                           <tr class="EditFormHeader">
                               <tr>
                                   <td>
                                       ShipCity:
                                   </td>
                                   <td>
                                       <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("ShipCity") %>'>
                                       </asp:TextBox>
                                   </td>
                               </tr>
                               <tr>
                                   <td>
                                       IsTrue
                                   </td>
                                   <td>
                                       <asp:CheckBox ID="CheckBox" runat="server" AutoPostBack="true" Checked='<%# Eval("IsTrue").ToString() == "TRUE" %>' />
                                   </td>
                               </tr>
                               <tr>
                                   <td align="right" colspan="2">
                                       <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                           runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                       </asp:Button
                                       <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                           CommandName="Cancel"></asp:Button>
                                   </td>
                               </tr>
                       </table>
                   </FormTemplate>
               </EditFormSettings>
           </MasterTableView>       
       </telerik:RadGrid>

Thanks,
Princy
0
Andrew
Top achievements
Rank 1
answered on 05 Jul 2013, 01:04 PM
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGridItems">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGridItems"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>              
        </AjaxSettings>
    </telerik:RadAjaxManager>
     
<div style=" margin:0 auto; width: 70%;">
    <fieldset>
    <legend>Item Definition</legend>
        <telerik:RadGrid ID="RadGridItems" runat="server" DataSourceID="objDataItems" GridLines="None" CssClass="RadGrid" PagerStyle-AlwaysVisible="true"
            AllowPaging="True" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" OnItemCommand="RadGridItems_ItemCommand"
            AllowAutomaticInserts="false" AllowSorting="true"  AutoGenerateColumns="false" CellSpacing="0">
            <MasterTableView  AllowFilteringByColumn="true" CommandItemDisplay="Top" DataKeyNames="ItemId"
                CommandItemSettings-ShowAddNewRecordButton="true" EditMode="EditForms" CommandItemSettings-AddNewRecordText="Add New Item">  
 
<EditFormSettings InsertCaption="Add New item" CaptionFormatString="Edit ItemId: {0}"
                    CaptionDataField="ItemId" EditFormType="Template">
                    <FormTemplate>
                    <telerik:RadFormDecorator ID="EditFormDecorator" DecorationZoneID="dec-zone-edit" runat="server" DecoratedControls="All" EnableRoundedCorners="true" />
                       <div id="dec-zone-edit" style="margin:0 auto 5px auto; width: 100% ">
                            <fieldset>
                            <legend>Item Definition</legend
                                <div style="margin: 0 auto 5px auto">                         
                                    <div style="margin: 0 auto; float: left; height: 200px; width:30%">
                                        <fieldset>
                                        <legend>Manufacturer Information</legend
                                            <table>                                                                                                                                                                                                                                                                                                       <table>
                                                <tr>
                                                    <td style="text-align:right" >
                                                        <telerik:RadComboBox ID="RadComboMfr" OnDataBound="Mfr_DataBound" Label="Manufacturer:" EmptyMessage="Choose Manufacturer" Filter="StartsWith"
                                                            DataSourceID="objDataManufacturers" runat="server" DataTextField="MfrName"
                                                            AutoPostBack="true" Sort="Ascending" Width="200px"  DataValueField="MfrId"
                                                             AllowCustomText="false" OnSelectedIndexChanged="RadComboMfr_SelectedIndexChanged"
                                                         </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr >
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboBrand" Label="Brand:" EmptyMessage="Choose Brand" Filter="StartsWith"
                                                            runat="server" AutoPostBack="true" Width="200px"  Sort="Ascending" AllowCustomText="false"
                                                             OnSelectedIndexChanged="RadComboBrand_SelectedIndexChanged">                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboSubBrand"  AllowCustomText="false" Label="Sub Brand:" EmptyMessage="Choose Sub Brand" Filter="StartsWith"
                                                            runat="server" Sort="Ascending" Width="200px" >                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>                                      
                                                    <td style="text-align:right">
                                                        <asp:Label ID="Label1" runat="server" Text="MFR Custom #: "></asp:Label
                                                        <telerik:RadTextBox ID="RadTextBox2"  runat="server" Width="200px" EmptyMessage="Enter Custom Mfr Number"></telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboPackaging" Label="Package Types:" EmptyMessage="Choose Package Types" Filter="StartsWith"
                                                            AllowCustomText="false" runat="server" CheckBoxes="true" Width="200px" DataSourceID="objDataPackaging" DataTextField="Name"
                                                            DataValueField="PackagingId">                                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>                                              
                                            </table>   
                                            <div>
 
                                            </div>                                      
                                        </fieldset>
                                    </div>
<div style="margin: 0 auto; height: 200px; width:30%">
                                        <fieldset >
                                        <legend>Location Information</legend>
                                            <table>
                                                <tr>
                                                    <td style="text-align:right" >
                                                        <telerik:RadComboBox ID="RadComboCountry" Label="Country:" EmptyMessage="Choose Country" Filter="StartsWith"
                                                            DataSourceID="objDataCountry" runat="server" DataTextField="CountryName"
                                                            AutoPostBack="true" Sort="Ascending" Width="200px"  DataValueField="CountryId"
                                                            AllowCustomText="false" OnSelectedIndexChanged="RadComboCountry_SelectedIndexChanged"
                                                            OnDataBound="Country_DataBound"
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr >
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboStateOrProvince" AllowCustomText="false" Label="State/Province:"
                                                         EmptyMessage="Choose State or Province" Filter="StartsWith" runat="server"
                                                         OnSelectedIndexChanged="RadComboStateOrProvince_SelectedIndexChanged"
                                                          AutoPostBack="true" Width="200px"  Sort="Ascending" >                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                 <tr >
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboStateOrProvinceRegion" AllowCustomText="false" Label="State/Province Region:" EmptyMessage="Choose State/Province Region"
                                                         Filter="StartsWith" runat="server" Width="200px"  Sort="Ascending">                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboRegion"  AllowCustomText="false" Label="Region:" EmptyMessage="Choose Region" Filter="StartsWith"
                                                          runat="server" Width="200px" Sort="Ascending"  AutoPostBack="true" OnSelectedIndexChanged="RadComboRegion_SelectedIndexChanged" >                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboLocale"  AllowCustomText="false" Label="Locale:" EmptyMessage="Choose Locale" Filter="StartsWith"
                                                          runat="server"  Sort="Ascending" Width="200px" >                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </div>                                  
                                </div>
 
<div style="float:left">                                  
                                    <telerik:RadButton ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel">
                                    </telerik:RadButton>                         
                                </div>                                 
                            </fieldset>   
                        </div>
      </FormTemplate>
                </EditFormSettings>
 
  <asp:ObjectDataSource ID="objDataManufacturers" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getCustomerManufacturers" InsertMethod="insertManufacturer" UpdateMethod="updateManufacturer"
        DeleteMethod="deleteManufacturer">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />        
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrName" DbType="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrName" DbType="String" />
            <asp:Parameter Name="MfrId" DbType="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrId" DbType="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataBrand" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getManufacturerBrands" InsertMethod="insertManufacturerBrand" UpdateMethod="updateManufacturerBrand"
        DeleteMethod="deleteManufacturerBrand">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />        
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="BrandName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="BrandName" DbType="String" />
             <asp:Parameter Name="BrandId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="BrandId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
    
    <asp:ObjectDataSource ID="objDataSubBrand" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getBrandSubBrands" InsertMethod="insertBrandSubBrand"
        UpdateMethod="updateBrandSubBrand" DeleteMethod="deleteBrandSubBrand">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="SubBrandName" DbType="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="SubBrandName" DbType="String" />
            <asp:Parameter Name="SubBrandId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="SubBrandId" DbType="Int32" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
     <asp:ObjectDataSource ID="objDataCountry" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getCountries" InsertMethod="insertCountry" UpdateMethod="updateCountry"
        DeleteMethod="deleteCountry">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />        
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="CountryName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="CountryName" Type="String" />
            <asp:Parameter Name="CountryId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="CountryId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataStateOrProvince" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getStateOrProvinces" InsertMethod="insertStateOrProvince" UpdateMethod="updateStateOrProvince"
        DeleteMethod="deleteStateOrProvince">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateOrProvinceName" Type="String" />
             <asp:Parameter Name="Code" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateOrProvinceName" Type="String" />
              <asp:Parameter Name="Code" Type="String" />
            <asp:Parameter Name="StateOrProvinceId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateOrProvinceId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataRegion" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getRegions" InsertMethod="insertRegion" UpdateMethod="updateRegion"
        DeleteMethod="deleteRegion">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" /> 
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="RegionName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="RegionName" Type="String" />
            <asp:Parameter Name="RegionId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="RegionId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataLocale" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getLocales" InsertMethod="insertLocale" UpdateMethod="updateLocale"
        DeleteMethod="deleteLocale">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />  
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="LocaleName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="LocaleName" Type="String" />
            <asp:Parameter Name="LocaleId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="LocaleId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataStateProvinceRegion" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getSPRegions" InsertMethod="insertSPRegion" UpdateMethod="updateSPRegion"
        DeleteMethod="deleteSPRegion">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />  
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateProvinceRegionName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateProvinceRegionName" Type="String" />
            <asp:Parameter Name="StateProvinceRegionId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="StateProvinceRegionId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>


protected override void Page_Load(object sender, EventArgs e)
   {
       if (base.loggedIn())
       {
           base.Page_Load(sender, e);
       }
 
   }
 
   protected void RadComboMfr_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
        
           ControlParameter ctrlParam = new ControlParameter();
           ctrlParam.DbType = DbType.Int32;
           ctrlParam.Name = "MfrId";
           ctrlParam.DefaultValue = e.Value;
           ctrlParam.PropertyName = "SelectedValue";
           RadComboBox RCBBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboBrand");
           ctrlParam.ControlID = RCBBrand.UniqueID;
           objDataBrand.SelectParameters["MfrId"] = ctrlParam;
           RadComboBox RCBSubBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboSubBrand");
           RCBBrand.Text = "";
           RCBSubBrand.Items.Clear();
           RCBSubBrand.Text = "";
       if (e.Value != "")
       {
           RCBBrand.DataTextField = "BrandName";
           RCBBrand.DataValueField = "BrandId";
           RCBBrand.DataSource = objDataBrand;
           RCBBrand.DataBind();
           RCBBrand.SortItems();
           RCBBrand.Items.Insert(0, new RadComboBoxItem("--Select a Brand--", null));
       }
   }
 
   protected void RadComboBrand_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e )
   {
       
       ControlParameter ctrlParam = new ControlParameter();
       ctrlParam.DbType = DbType.Int32;
       ctrlParam.Name = "BrandId";
       ctrlParam.DefaultValue = e.Value;
       ctrlParam.PropertyName = "SelectedValue";
       RadComboBox RCBSubBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboSubBrand");
       ctrlParam.ControlID = RCBSubBrand.UniqueID;
       objDataSubBrand.SelectParameters["BrandId"] = ctrlParam;
 
       if (e.Value != "")
       {
           RCBSubBrand.Text = "";
           RCBSubBrand.Items.Clear();
           RCBSubBrand.Text = "";
           RCBSubBrand.DataTextField = "SubBrandName";
           RCBSubBrand.DataSource = objDataSubBrand;
           RCBSubBrand.DataBind();
           RCBSubBrand.SortItems();
           RCBSubBrand.Items.Insert(0, new RadComboBoxItem("--Select a Sub Brand--", null));
       }
   }
 
   protected void RadComboCountry_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
        
       ControlParameter ctrlParam = new ControlParameter();
       ctrlParam.DbType = DbType.Int32;
       ctrlParam.Name = "CountryId";
       ctrlParam.DefaultValue = e.Value;
       ctrlParam.PropertyName = "SelectedValue";
 
       RadComboBox RCBRegion = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboRegion");
       ctrlParam.ControlID = RCBRegion.UniqueID;
       objDataRegion.SelectParameters["CountryId"] = ctrlParam;
 
       ControlParameter ctrlParam2 = new ControlParameter();
       ctrlParam2.DbType = DbType.Int32;
       ctrlParam2.Name = "CountryId";
       ctrlParam2.DefaultValue = e.Value;
       ctrlParam2.PropertyName = "SelectedValue";
 
       RadComboBox RCBStateOrProvince = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboStateOrProvince");
       ctrlParam2.ControlID = RCBStateOrProvince.UniqueID;
       objDataStateOrProvince.SelectParameters["CountryId"] = ctrlParam2;
 
       RadComboBox RCBLocale = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboLocale");
 
       if (e.Value != "")
       {
           RCBRegion.Text = "";
 
           RCBStateOrProvince.Text = "";
 
           RCBLocale.Items.Clear();
           RCBLocale.Text = "";
 
           RCBRegion.DataTextField = "RegionName";
           RCBRegion.DataValueField = "RegionId";
           RCBRegion.DataSource = objDataRegion;
           RCBRegion.DataBind();     
           RCBRegion.SortItems();
           RCBRegion.Items.Insert(0, new RadComboBoxItem("Select a Region",null));
 
           RCBStateOrProvince.DataTextField = "StateOrProvinceName";
           RCBStateOrProvince.DataValueField = "StateOrProvinceId";
           RCBStateOrProvince.DataSource = objDataStateOrProvince;       
           RCBStateOrProvince.DataBind();
           RCBStateOrProvince.SortItems();
           RCBStateOrProvince.Items.Insert(0, new RadComboBoxItem("--Select a State or Province--",null));
       }
   }
 
   protected void RadComboStateOrProvince_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
       
       ControlParameter ctrlParam = new ControlParameter();
       ctrlParam.DbType = DbType.Int32;
       ctrlParam.Name = "StateOrProvinceId";
       ctrlParam.DefaultValue = e.Value;
       ctrlParam.PropertyName = "SelectedValue";
       RadComboBox RCBStateProvinceRegion = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboStateOrProvinceRegion");
       ctrlParam.ControlID = RCBStateProvinceRegion.UniqueID;
       objDataStateProvinceRegion.SelectParameters["StateOrProvinceId"] = ctrlParam;
       if (e.Value != "")
       {
           RCBStateProvinceRegion.Text = "";
           RCBStateProvinceRegion.Items.Clear();
           RCBStateProvinceRegion.Text = "";
           RCBStateProvinceRegion.DataTextField = "StateProvinceRegionName";
           RCBStateProvinceRegion.DataSource = objDataStateProvinceRegion;
           RCBStateProvinceRegion.DataBind();
           RCBStateProvinceRegion.SortItems();
           RCBStateProvinceRegion.Items.Insert(0, new RadComboBoxItem("--Select a State/Province Region--", null));
       }
   }
 
   protected void RadComboRegion_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
       
       ControlParameter ctrlParam = new ControlParameter();
       ctrlParam.DbType = DbType.Int32;
       ctrlParam.Name = "RegionId";
       ctrlParam.DefaultValue = e.Value;
       ctrlParam.PropertyName = "SelectedValue";
       RadComboBox RCBLocale = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboLocale");
       ctrlParam.ControlID = RCBLocale.UniqueID;
       objDataLocale.SelectParameters["RegionId"] = ctrlParam;
 
       if (e.Value != "")
       {
           RCBLocale.Text = "";
           RCBLocale.Items.Clear();
           RCBLocale.Text = "";
           RCBLocale.DataTextField = "LocaleName";
           RCBLocale.DataSource = objDataLocale;
           RCBLocale.DataBind();
           RCBLocale.SortItems();
           RCBLocale.Items.Insert(0, new RadComboBoxItem("--Select a Locale--", null));
       }
   }
 
    
 
   protected void Country_DataBound(object sender, EventArgs e)
   {
       RadComboBox RCBCountry = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboCountry");
       RCBCountry.SortItems();
       RCBCountry.Items.Insert(0, new RadComboBoxItem("--Select a Country--",null));
   }
 
   protected void Mfr_DataBound(object sender, EventArgs e)
   {
       RadComboBox RCBMfr = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboMfr");
       RCBMfr.SortItems();
       RCBMfr.Items.Insert(0, new RadComboBoxItem("--Select a Manufacturer--", null));
   }
0
Andrew
Top achievements
Rank 1
answered on 05 Jul 2013, 02:06 PM
<div style=" margin:0 auto; width: 70%;">
    <fieldset>
    <legend>Item Definition</legend>
        <telerik:RadGrid ID="RadGridItems" runat="server" DataSourceID="objDataItems" GridLines="None" CssClass="RadGrid" PagerStyle-AlwaysVisible="true"
            AllowPaging="True" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" OnItemCommand="RadGridItems_ItemCommand"
            AllowAutomaticInserts="false" AllowSorting="true"  AutoGenerateColumns="false" CellSpacing="0">
            <MasterTableView  AllowFilteringByColumn="true" CommandItemDisplay="Top" DataKeyNames="ItemId"
                CommandItemSettings-ShowAddNewRecordButton="true" EditMode="EditForms" CommandItemSettings-AddNewRecordText="Add New Item">
 
<EditFormSettings InsertCaption="Add New item" CaptionFormatString="Edit ItemId: {0}"
                    CaptionDataField="ItemId" EditFormType="Template">
                    <FormTemplate>
                    <telerik:RadFormDecorator ID="EditFormDecorator" DecorationZoneID="dec-zone-edit" runat="server" DecoratedControls="All" EnableRoundedCorners="true" />
                       <div id="dec-zone-edit" style="margin:0 auto 5px auto; width: 100% ">
                            <fieldset>
                            <legend>Item Definition</legend
                                <div style="margin: 0 auto 5px auto">                         
                                    <div style="margin: 0 auto; float: left; height: 200px; width:30%">
                                        <fieldset>
                                        <legend>Manufacturer Information</legend
                                            <table>                                                                                                                                                                                                                                                                                                       <table>
                                                <tr>
                                                    <td style="text-align:right" >
                                                        <telerik:RadComboBox ID="RadComboMfr" OnDataBound="Mfr_DataBound" Label="Manufacturer:" EmptyMessage="Choose Manufacturer" Filter="StartsWith"
                                                            DataSourceID="objDataManufacturers" runat="server" DataTextField="MfrName"
                                                            AutoPostBack="true" Sort="Ascending" Width="200px"  DataValueField="MfrId"
                                                             AllowCustomText="false" OnSelectedIndexChanged="RadComboMfr_SelectedIndexChanged"
                                                         </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr >
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboBrand" Label="Brand:" EmptyMessage="Choose Brand" Filter="StartsWith"
                                                            runat="server" AutoPostBack="true" Width="200px"  Sort="Ascending" AllowCustomText="false"
                                                             OnSelectedIndexChanged="RadComboBrand_SelectedIndexChanged">                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboSubBrand"  AllowCustomText="false" Label="Sub Brand:" EmptyMessage="Choose Sub Brand" Filter="StartsWith"
                                                            runat="server" Sort="Ascending" Width="200px" >                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>
                                                <tr>                                      
                                                    <td style="text-align:right">
                                                        <asp:Label ID="Label1" runat="server" Text="MFR Custom #: "></asp:Label
                                                        <telerik:RadTextBox ID="RadTextBox2"  runat="server" Width="200px" EmptyMessage="Enter Custom Mfr Number"></telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="text-align:right">
                                                        <telerik:RadComboBox ID="RadComboPackaging" Label="Package Types:" EmptyMessage="Choose Package Types" Filter="StartsWith"
                                                            AllowCustomText="false" runat="server" CheckBoxes="true" Width="200px" DataSourceID="objDataPackaging" DataTextField="Name"
                                                            DataValueField="PackagingId">                                                           
                                                        </telerik:RadComboBox>
                                                    </td>
                                                </tr>                                              
                                            </table>   
                                            <div>
 
                                            </div>                                      
                                        </fieldset>
                                    </div>
 
<div style="float:left">                                  
                                    <telerik:RadButton ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel">
                                    </telerik:RadButton>                         
                                </div>                                 
                            </fieldset>   
                        </div>
                    </FormTemplate>
                </EditFormSettings>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn" EditImageUrl="~/Img/icons/table_edit.png"
                                           ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" />
                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="" UniqueName="DeleteColumn"
                        ImageUrl="~/Img/icons/delete.png" ConfirmTextFields="ItemId" ConfirmTextFormatString="Are you sure you want to delete {0}?"
                        HeaderStyle-Width="25px" />
                    <telerik:GridBoundColumn DataField="ItemId" UniqueName="ItemId" HeaderText="Item Id" Visible="true" />
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
 
 <asp:ObjectDataSource ID="objDataManufacturers" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getCustomerManufacturers" InsertMethod="insertManufacturer" UpdateMethod="updateManufacturer"
        DeleteMethod="deleteManufacturer">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />        
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrName" DbType="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrName" DbType="String" />
            <asp:Parameter Name="MfrId" DbType="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="MfrId" DbType="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
 
    <asp:ObjectDataSource ID="objDataBrand" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getManufacturerBrands" InsertMethod="insertManufacturerBrand" UpdateMethod="updateManufacturerBrand"
        DeleteMethod="deleteManufacturerBrand">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />        
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="BrandName" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="BrandName" DbType="String" />
             <asp:Parameter Name="BrandId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="BrandId" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
    
    <asp:ObjectDataSource ID="objDataSubBrand" runat="server" TypeName="NexgenWebClassLib.Controller.SIPWrapper"
        SelectMethod="getBrandSubBrands" InsertMethod="insertBrandSubBrand"
        UpdateMethod="updateBrandSubBrand" DeleteMethod="deleteBrandSubBrand">
        <SelectParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
        </SelectParameters>
        <InsertParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="SubBrandName" DbType="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
            <asp:Parameter Name="SubBrandName" DbType="String" />
            <asp:Parameter Name="SubBrandId" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:SessionParameter DbType="String" Name="connectionString" SessionField="SelectedConnectionString" />
             <asp:Parameter Name="SubBrandId" DbType="Int32" />
        </DeleteParameters>
    </asp:ObjectDataSource>
protected void Mfr_DataBound(object sender, EventArgs e)
{
    RadComboBox RCBMfr = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboMfr");
    RCBMfr.SortItems();
    RCBMfr.Items.Insert(0, new RadComboBoxItem("--Select a Manufacturer--", null));
}
 
protected override void Page_Load(object sender, EventArgs e)
{
    if (base.loggedIn())
    {
        base.Page_Load(sender, e);
    }
 
}
 
protected void RadComboMfr_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
     
        ControlParameter ctrlParam = new ControlParameter();
        ctrlParam.DbType = DbType.Int32;
        ctrlParam.Name = "MfrId";
        ctrlParam.DefaultValue = e.Value;
        ctrlParam.PropertyName = "SelectedValue";
        RadComboBox RCBBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboBrand");
        ctrlParam.ControlID = RCBBrand.UniqueID;
        objDataBrand.SelectParameters["MfrId"] = ctrlParam;
        RadComboBox RCBSubBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboSubBrand");
        RCBBrand.Text = "";
        RCBSubBrand.Items.Clear();
        RCBSubBrand.Text = "";
    if (e.Value != "")
    {
        RCBBrand.DataTextField = "BrandName";
        RCBBrand.DataValueField = "BrandId";
        RCBBrand.DataSource = objDataBrand;
        RCBBrand.DataBind();
        RCBBrand.SortItems();
        RCBBrand.Items.Insert(0, new RadComboBoxItem("--Select a Brand--", null));
    }
}
 
protected void RadComboBrand_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e )
{
    
    ControlParameter ctrlParam = new ControlParameter();
    ctrlParam.DbType = DbType.Int32;
    ctrlParam.Name = "BrandId";
    ctrlParam.DefaultValue = e.Value;
    ctrlParam.PropertyName = "SelectedValue";
    RadComboBox RCBSubBrand = (RadComboBox)(sender as RadComboBox).NamingContainer.FindControl("RadComboSubBrand");
    ctrlParam.ControlID = RCBSubBrand.UniqueID;
    objDataSubBrand.SelectParameters["BrandId"] = ctrlParam;
 
    if (e.Value != "")
    {
        RCBSubBrand.Text = "";
        RCBSubBrand.Items.Clear();
        RCBSubBrand.Text = "";
        RCBSubBrand.DataTextField = "SubBrandName";
        RCBSubBrand.DataSource = objDataSubBrand;
        RCBSubBrand.DataBind();
        RCBSubBrand.SortItems();
        RCBSubBrand.Items.Insert(0, new RadComboBoxItem("--Select a Sub Brand--", null));
    }
}
0
Kostadin
Telerik team
answered on 10 Jul 2013, 08:17 AM
Hi Andrew,

Note that the edit form remains open after a postback so if you want to close it you have to do it manually. You could use the following approach to close multiple edit forms :
if (RadGrid1.EditItems.Count > 0)
{
    foreach (GridEditableItem item in RadGrid1.EditItems)
    {
        item.Edit = false;
    }
}

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Andrew
Top achievements
Rank 1
answered on 10 Jul 2013, 06:51 PM
Hello Kostadin,

I did try to add you suggestion to the ItemCommand event of the RadGrid but had no luck.

I have some of the comboboxes pre-populated ondatabound to values specified by an objectdatasource, after this change the cancel button does not work even after seemingly no postbacks (example: no changes to radcomboxes to select new values).  The insertitem form does close on cancel before any changes have been made to the comboboxes, but also does not close on cancel once a combobox has been changed and performed an autopostback. 

I have tried:

protected void RadGridItems_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
    {
        GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGridItems.MasterTableView.GetColumn("EditColumn");
        editColumn.Visible = false;
        RadGridItems.MasterTableView.ClearEditItems();
        RadGridItems.Rebind();
    }
    else if (e.CommandName == RadGrid.UpdateCommandName)
    {
        GridEditFormItem form = (GridEditFormItem)e.Item;
        updateItemGridParameters(source, form, objDataItems.UpdateParameters);
        //TODO Transfer values to datasource
    }
    else if (e.CommandName == RadGrid.PerformInsertCommandName)
    {
        GridEditFormInsertItem form = (GridEditFormInsertItem)e.Item;
        updateItemGridParameters(source, form, objDataItems.InsertParameters);
        GridEditableItem editedItem = e.Item as GridEditableItem;
        //TODO Transfer values to datasource
    }
    else if (e.CommandName == RadGrid.CancelCommandName)
    {          
        GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGridItems.MasterTableView.GetColumn("EditColumn");
        if (!editColumn.Visible)
            editColumn.Visible = true;
        //RadGridItems.MasterTableView.ClearEditItems();
        //RadGridItems.Rebind();
    }
    else
    {
        GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGridItems.MasterTableView.GetColumn("EditColumn");
        if (!editColumn.Visible)
            editColumn.Visible = true;
    }
 
}

but have not had any luck getting forms to close properly.

I am creating setting my RadComboBox parameters and binding properties in ItemCreated and then binding in ItemDataBound of the RadGrid respectively. 

Eventually I will be adding manual insert, update commands and currently autoinsert and autoupdate are set to false. Is there a place in the page creation/data binding event sequence that I need to rebind something or clear something after or before the postbacks in order to have the RadGrid acknowledge the cancel command?

Thank you for your help,

-Andrew
0
Andrew
Top achievements
Rank 1
answered on 12 Jul 2013, 03:27 PM
Problem behavior has been resolved. There was an issue with the ObjectDataSource parameter list having a ControlParameter persisted that consisted of a control that was no longer available after the edit form was closed on cancel. This was only noticed after turning the ajax manager off for the radgrid because the grid was hiding the exception (and subsequently doing nothing because there was an exception thrown). 
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or